hampom / bari-kata-functional
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/hampom/bari-kata-functional
Requires
- php: >=8.2
 - hampom/bari-kata: 0.0.1
 
Requires (Dev)
- carthage-software/mago: 1.0.0-beta.14
 - dg/bypass-finals: ^1.9
 - phpunit/phpunit: ^12
 
README
https://github.com/hampom/BariKata のプラグイン集です
プラグイン
- FilterPlugin
 - MapPlugin
 - ReducePlugin
 
インストール
Composer を使ってインストールできます
composer require hampom/barikata-functional
使い方
基本的な使い方の例をいくつか示します
FilterPlugin
$collection = new TypedCollection('int', [1, 2, 3, 4, 5], [ new FilterPlugin() ]); $results = $collection->filter(fn(int $x) => $x % 2 === 0); // -> [2, 4]
MapPlugin
$collection = new TypedCollection('int', [1, 2, 3, 4, 5], [ new MapPlugin() ]); $results = $collection->map(fn(int $x) => $x * 2); // -> [2, 4, 6, 8, 10]
ReducePlugin
$collection = new TypedCollection('int', [1, 2, 3, 4, 5], [ new ReducePlugin() ]); $results = $collection->reduce(fn(int $carry, int $x) => $carry + $x, 0); // -> 15