-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[0.3.0] Remove circular dependency on
illuminate/collections
(#168)
* Move illuminate/collections to a dev dependency only * Remove internal use of collections * try removing collections in tests * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Fix code styling * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Fix code styling * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Fix collection dependency check * Remove collections from data providers when not installed * Fix code styling * Refactor tests that didn't require collections * Formatting * Fix test * Update .github/workflows/tests.yml * wip --------- Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: Dries Vints <dries@vints.be> Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: crynobone <crynobone@users.noreply.github.com> Co-authored-by: jessarcher <jessarcher@users.noreply.github.com>
- Loading branch information
1 parent
8499792
commit 5f99189
Showing
27 changed files
with
354 additions
and
223 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
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,53 @@ | ||
<?php | ||
|
||
namespace Laravel\Prompts\Support; | ||
|
||
use Closure; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class Utils | ||
{ | ||
/** | ||
* Determine if all items in an array match a truth test. | ||
* | ||
* @param array<array-key, mixed> $values | ||
*/ | ||
public static function allMatch(array $values, Closure $callback): bool | ||
{ | ||
foreach ($values as $key => $value) { | ||
if (! $callback($value, $key)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Get the last item from an array or null if it doesn't exist. | ||
* | ||
* @param array<array-key, mixed> $array | ||
*/ | ||
public static function last(array $array): mixed | ||
{ | ||
return array_reverse($array)[0] ?? null; | ||
} | ||
|
||
/** | ||
* Returns the key of the first element in the array that satisfies the callback. | ||
* | ||
* @param array<array-key, mixed> $array | ||
*/ | ||
public static function search(array $array, Closure $callback): int|string|false | ||
{ | ||
foreach ($array as $key => $value) { | ||
if ($callback($value, $key)) { | ||
return $key; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
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
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
Oops, something went wrong.