ta-tikoma / bind
bind method for binding argument to callable
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/ta-tikoma/bind
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.4
README
There is only two functions in this package: bind and flip
Install
Examples
Example 1
Before
array_map(static fn (string $s) => substr($s, 2), ['a_bar', 'a_foo', 'a_boo'])
After
array_map(bind(substr(...), 2), ['a_bar', 'a_foo', 'a_boo'])
Example 2
Before
$result = 'Hello World' |> static fn (string $s) => explode(' ', $s) |> static fn (array $a) => array_filter($a, static fn (string $s) => str_starts_with($s, 'H'))
After
$result = 'Hello World' |> bind(flip(explode(...)), ' ') |> bind(array_filter(...), bind(str_starts_with(...), 'H'))