cdn77 / functions
PHP Functions
Installs: 36 818
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Requires
- php: ^8.1
- ext-ds: *
- phpoption/phpoption: ^1.9
Requires (Dev)
- cdn77/coding-standard: ^7.0
- ergebnis/composer-normalize: ^2.23
- icanhazstring/composer-unused: ^0.8.0
- infection/infection: ^0.27.0
- maglnet/composer-require-checker: ^4.0
- php-ds/php-ds: ^1.4
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.3
- phpstan/phpstan-phpunit: ^1.0.0
- phpunit/phpunit: ^10.3
- psalm/plugin-phpunit: ^0.18.0
- roave/infection-static-analysis-plugin: ^1.13
- vimeo/psalm: ^5.0
This package is auto-updated.
Last update: 2024-03-23 21:21:49 UTC
README
Functions
absurd()
Function that should have never been called.
Useful for default
case in exhaustive matching.
noop()
Does nothing. Useful e.g. for match
expression that currently supports single-line expressions in blocks.
match ($val) { '1' => throw new Exception, '2' => foo(), default => noop(), };
Ds
mapFromEntries()
Creates a map from an iterable of entries.
use function Cdn77\Functions\mapFromEntries; $map = mapFromEntries([ ['foo', 'bar'], ['baz', 'qux'], ]); assert($map->get('foo') === 'bar');
Iterable
find()
Finds a value in an iterable.
use function Cdn77\Functions\Iterable\find; $iterable = [0, 1, 2, 3]; $option = find($iterable, static fn (mixed $_, int $value) => $value < 2); assert($option->get() === 0);