Returns true if a value is present in an iterable.
use function Jungi\Common\in_iterable;
$iterable = [new Phone('(656) 456-7765'), new Phone('(321) 456-1234')];
assert(true === in_iterable(new Phone('(321) 456-1234'), $iterable));
assert(false === in_iterable(new Phone('(232) 456-1234'), $iterable));
iterable_unique(iterable $iterable): iterable
Returns an iterable without duplicates.
use function Jungi\Common\iterable_unique;
use function Jungi\Common\array_equals;
$unique = iterable_unique([
new Phone('(321) 456-1234'),
new Phone('(465) 799-4566'),
new Phone('(321) 456-1234'),
]);
$expected = [
new Phone('(321) 456-1234'),
new Phone('(465) 799-4566'),
];
assert(true === array_equals($expected, $unique));
Returns the first key where the given value is equal. If the value is not found, false is returned.
use function Jungi\Common\iterable_search;
assert(2 === iterable_search(new Phone('(321) 456-1234'), [
new Phone('(321) 456-1234'),
new Phone('(465) 799-4566'),
new Phone('(321) 456-1234'),
]);
assert(false === iterable_search(new Phone('(444) 555-1234'), [
new Phone('(321) 456-1234'),
new Phone('(465) 799-4566'),
new Phone('(321) 456-1234'),
]);