⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Releases: samsonasik/ArrayLookup

Released: ArrayLookup 2.4.0

12 Feb 00:40
2.4.0
83ad00b

Choose a tag to compare

ci build Code Coverage PHPStan

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)) // true

2. 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)) // true

Full Changelog: 2.3.1...2.4.0

Released: ArrayLookup 2.3.1

09 Feb 23:28
2.3.1
dd3f2b8

Choose a tag to compare

ci build Code Coverage PHPStan

What's Changed

Full Changelog: 2.3.0...2.3.1

Released: ArrayLookup 2.3.0

25 Jan 20:15
2.3.0
0726711

Choose a tag to compare

ci build Code Coverage PHPStan

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)) // false

2. 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)) // false

3. 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)) // false

Full Changelog: 2.2.0...2.3.0

Released: ArrayLookup 2.2.0

11 Jan 15:22
2.2.0
4ce3b4d

Choose a tag to compare

ci build Code Coverage PHPStan Downloads

What's Changed

Full Changelog: 2.1.1...2.2.0

Released: ArrayLookup 2.1.1

16 Dec 08:12
2.1.1
1e0c0e4

Choose a tag to compare

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

04 Dec 22:55
2.1.0
e61c61c

Choose a tag to compare

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

25 Jun 02:40
2.0.3
3b815db

Choose a tag to compare

[DX] Early check nullable any type on Filter

Released: ArrayLookup 2.0.2

20 Jun 02:00
2.0.2
cb4cc9a

Choose a tag to compare

[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

05 Jun 16:55
2.0.1
ce1fb91

Choose a tag to compare

What's Changed

Enhancement

  • [Doc] Better documentation: make list number clickable
  • [DX] include DX improvement for callable filter error message that can possibly returns ReflectionUnionType or ReflectionIntersectionType

Changelog 2.0.0...2.0.1

Released: ArrayLookup 2.0.0

28 Dec 13:26
2.0.0
f2cb43a

Choose a tag to compare

What's Changed

🚀🚀🚀 It brings performance improvement with 🚀 Faster process with early validate filter callable before loop

Enhancement

Full Changelog: 1.8.1...2.0.0