-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8b7873
commit fb5aa91
Showing
5 changed files
with
77 additions
and
0 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,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Nexus framework. | ||
* | ||
* (c) John Paul E. Balandan, CPA <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nexus\Collection\Operation; | ||
|
||
use Nexus\Collection\CollectionInterface; | ||
|
||
/** | ||
* @template TKey | ||
* @template T | ||
*/ | ||
interface Map | ||
{ | ||
/** | ||
* Returns a new collection consisting of items transformed by applying | ||
* the mapping function `$predicate`. | ||
* | ||
* Only the values are passed to the closure. If you want to pass only | ||
* the keys, you need to use `CollectionInterface::mapKeys()`. If you | ||
* want both keys and values, you need `CollectionInterface::mapWithKey()`. | ||
* | ||
* ``` | ||
* Collection::wrap([1, 2, 3, 4, 5])->map(static fn(int $item): int => $item ** 2)->all(); | ||
* => [1, 4, 9, 16, 25] | ||
* ``` | ||
* | ||
* @template U | ||
* | ||
* @param (\Closure(T): U) $predicate | ||
* | ||
* @return CollectionInterface<TKey, U> | ||
*/ | ||
public function map(\Closure $predicate): CollectionInterface; | ||
} |
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