-
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 <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * Fix code styling * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * Fix code styling * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * 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 <[email protected]> Co-authored-by: Dries Vints <[email protected]> Co-authored-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: crynobone <[email protected]> Co-authored-by: jessarcher <[email protected]>
- 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.