-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(macros): Add JSON macro to Collection class
- Introduce a new `CollectionMacMini` that provides a `json()` method - Update `CommitCommand` to utilize the new Collection method for JSON decoding - Enhance `_ide_helper.php` by correcting namespace references for `Str` and `Collection` - Improve code organization and maintainability with added macros
- Loading branch information
ityaozm@gmail.com
committed
Nov 19, 2024
1 parent
974bd06
commit 46dde21
Showing
4 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the guanguans/ai-commit. | ||
* | ||
* (c) guanguans <ityaozm@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled. | ||
*/ | ||
|
||
namespace App\Macros; | ||
|
||
/** | ||
* @mixin \Illuminate\Support\Collection | ||
*/ | ||
class CollectionMacro | ||
{ | ||
/** | ||
* @noinspection JsonEncodingApiUsageInspection | ||
* @noinspection PhpMethodParametersCountMismatchInspection | ||
*/ | ||
public static function json(): callable | ||
{ | ||
return static function (string $json, int $depth = 512, int $options = 0): self { | ||
return new static(json_decode( | ||
$json, | ||
true, | ||
$depth, | ||
$options | ||
)); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters