Releases: samsonasik/ArrayLookup
Released: ArrayLookup 2.4.0
What's Changed
- Add Interval feature to verify in interval range: isInclusiveOf() and isExclusiveOf() by @samsonasik in #38
We already have AtLeast and AtMost to verify the lower and upper bounds. Now it’s time for something in between, meet Interval!
1. Interval::isInclusiveOf()
It verify that data has filtered found items within min and max (inclusive).
use ArrayLookup\Interval;
$orders = [
['status' => 'paid'],
['status' => 'paid'],
['status' => 'pending'],
['status' => 'paid'],
];
$filter = static fn(array $order): bool => $order['status'] === 'paid';
// inclusive means min and max boundaries are allowed
var_dump(Interval::isInclusiveOf($orders, $filter, 3, 5)) // true
var_dump(Interval::isInclusiveOf($orders, $filter, 2, 5)) // true2. Interval::isExclusiveOf()
It verify that data has filtered found items between min and max (exclusive).
use ArrayLookup\Interval;
$orders = [
['status' => 'paid'],
['status' => 'paid'],
['status' => 'pending'],
['status' => 'paid'],
];
$filter = static fn(array $order): bool => $order['status'] === 'paid';
// exclusive means strictly between min and max
var_dump(Interval::isExclusiveOf($orders, $filter, 3, 5)) // false
var_dump(Interval::isExclusiveOf($orders, $filter, 2, 5)) // trueFull Changelog: 2.3.1...2.4.0
Released: ArrayLookup 2.3.1
What's Changed
- Fix unioned intersection on Assert Filter by @samsonasik in #37
Full Changelog: 2.3.0...2.3.1
Released: ArrayLookup 2.3.0
What's Changed
- Add
AtMost, this is to verify "no more than" :)
1. AtMost::once()
It verify that data has filtered found item at most once.
use ArrayLookup\AtMost;
$data = [1, 2, 3];
$filter = static fn($datum): bool => $datum === 1;
var_dump(AtMost::once($data, $filter)) // true
$data = [1, "1", 3];
$filter = static fn($datum): bool => $datum == 1;
var_dump(AtMost::once($data, $filter)) // false
// WITH key array included, pass $key variable as 2nd arg on filter to be used in filter
$data = ['abc', 'def', 'some test'];
$filter = static fn(string $datum, int $key): bool => $datum === 'def' && $key === 1;
var_dump(AtMost::once($data, $filter)) // true
$data = ['abc', 'def', 'some test'];
$filter = static fn(string $datum, int $key): bool => $key > 0;
var_dump(AtMost::once($data, $filter)) // false2. AtMost::twice()
It verify that data has filtered found items at most twice.
use ArrayLookup\AtMost;
$data = [1, "1", 2];
$filter = static fn($datum): bool => $datum == 1;
var_dump(AtMost::twice($data, $filter)) // true
$data = [1, "1", 2, 1];
$filter = static fn($datum): bool => $datum == 1;
var_dump(AtMost::twice($data, $filter)) // false3. AtMost::times()
It verify that data has filtered found items at most times passed in 3rd arg.
use ArrayLookup\AtMost;
$data = [false, null, 0];
$filter = static fn($datum): bool => ! $datum;
$times = 3;
var_dump(AtMost::times($data, $filter, $times)) // true
$data = [false, null, 0, 0];
$filter = static fn($datum): bool => ! $datum;
$times = 3;
var_dump(AtMost::times($data, $filter, $times)) // falseFull Changelog: 2.2.0...2.3.0
Released: ArrayLookup 2.2.0
What's Changed
- Allow webmozart/assert version ^2.1 by @samsonasik in #35
Full Changelog: 2.1.1...2.2.0
Released: ArrayLookup 2.1.1
What's Changed
- Make faster search on Finder::last() on SplFixedArray data by @samsonasik in #34
Full Changelog: 2.1.0...2.1.1
Released: ArrayLookup 2.1.0
Feature
Add new Finder::partition() functionality:
It splits data into 2 arrays: matching and non-matching, instead of 2 loops to get match and non-match, it just use single iteration, and already get both matching and non-matching data.
The valid example for this:
<?php
// Import CSV data and separate valid/invalid rows in one pass
$csvRows = $csvParser->parse('users.csv');
[$validUsers, $invalidUsers] = Finder::partition(
$csvRows,
fn($row) => $validator->validate($row)->isValid()
);
// Bulk insert valid users
$userRepository->bulkInsert($validUsers);
// Generate error report for invalid rows
$reportGenerator->createErrorReport($invalidUsers);Full Changelog: 2.0.3...2.1.0
Released: ArrayLookup 2.0.3
[DX] Early check nullable any type on Filter
Released: ArrayLookup 2.0.2
[DX] Fix message: no return means return mixed
[DX] Fix nullable message
Full Changelog: 2.0.1...2.0.2
Released: ArrayLookup 2.0.1
What's Changed
Enhancement
- [Doc] Better documentation: make list number clickable
- [DX] include DX improvement for callable filter error message that can possibly returns
ReflectionUnionTypeorReflectionIntersectionType
Changelog 2.0.0...2.0.1
Released: ArrayLookup 2.0.0
What's Changed
🚀🚀🚀 It brings performance improvement with 🚀 Faster process with early validate filter callable before loop
Enhancement
- Only upload test coverage on non-fork by @samsonasik in #27
- Bump to PHPStan 2.0 by @samsonasik in #28
- Version 2: 🚀 Faster process with early validate filter before loop by @samsonasik in #29
- Version 2: bump requirement to php 8.2 by @samsonasik in #30
Full Changelog: 1.8.1...2.0.0