Skip to content

Releases: samsonasik/ArrayLookup

Released: ArrayLookup 1.6.0

30 Mar 16:32
1.6.0
be860ef
Compare
Choose a tag to compare

1.6.0

ci build Code Coverage PHPStan

This bring new ability to gather only limited found data on Finder::rows():

$data = [1, 2];
$filter = static fn($datum): bool => $datum >= 0;
$limit = 1;

var_dump(
    Finder::rows($data, $filter, limit: $limit)
); // [1]

Released: ArrayLookup 1.5.0

06 Mar 23:48
1.5.0
f86a0e1
Compare
Choose a tag to compare

1.5.0

ci build Code Coverage PHPStan

This bring some behaviour changes on Finder::rows() to keep string key when $preserveKey is disabled.

  • #14 [Finder] Fix string key on rows get when preserveKey disabled
  • #15 [Finder] Check numeric type as same with int on Finder::rows()
  • #16 [Finder] Don't increment new key when preserveKey

Released ArrayLookup 1.4.0

27 Feb 22:24
1.4.0
b5b6c20
Compare
Choose a tag to compare

1.4.0

ci build Code Coverage PHPStan

Add new Finder::rows() with the functionality is to get rows data filtered found:

use ArrayLookup\Finder;

$data = [6, 7, 8, 9];
var_dump(Finder::rows(
    $data,
    static fn($datum): bool => $datum > 6
)); // [7, 8, 9]

// WITH key array included, pass $key variable as 2nd arg on  filter to be used in filter
var_dump(Finder::rows(
    $data,
    static fn($datum, $key): bool => $datum > 6 && $key > 1
)); // [8, 9]

// ... with PRESERVE original key
var_dump(Finder::rows(
    $data,
    static fn ($datum): bool => $datum > 6,
    true
)); // [1 => 7, 2 => 8, 3 => 9]

1.3.0

14 Jan 11:38
1.3.0
a387403
Compare
Choose a tag to compare

1.3.0

ci build Code Coverage PHPStan

Add $preserveKey flag ability to not preserve key on Finder::last()

$data = [6, 7, 8, 9];
$filter = static fn ($datum): bool => $datum > 5;

// RETURN the Array key, pass true to 3rd arg

// ... with PRESERVE original key
var_dump(\ArrayLookup\Finder::last($data, $filter, true)); // 3

// ... with RESORT key, first key is last record, pass false to 4th arg
var_dump(\ArrayLookup\Finder::last($data, $filter, true, false)); // 0

1.2.0

12 Jan 17:06
1.2.0
cd0666c
Compare
Choose a tag to compare

1.2.0

ci build Code Coverage PHPStan

To allow search in both first or last to get the key instead of the row:

$data = [1, 2, 3];
$filter = static fn($datum): bool => $datum >= 1;

// RETURN the Array key, pass true to 3rd arg
var_dump(\ArrayLookup\Finder::first($data, $filter, true)) // 0

// RETURN the Array key, pass true to 3rd arg
var_dump(\ArrayLookup\Finder::last($data, $filter, true)) // 2

1.1.0

12 Jan 09:09
1.1.0
c9d6fbd
Compare
Choose a tag to compare

1.1.0

ci build Code Coverage PHPStan

Added ability to filter by key as well in all AtLeast, Only, and Finder:

$data = ['abc def', 'def ghi', 'ghi jkl'];

$filter = static fn(string $datum, int $key): bool => str_contains($datum, 'def') && $key >= 0;
Atleast::once($data, $filter); // true

$filter = static fn(string $datum, int $key): bool => str_contains($datum, 'not found datum') && $key >= 0;
Atleast::once($data, $filter); // false

1.0.1

11 Jan 04:08
1.0.1
4fcd275
Compare
Choose a tag to compare

ci build Code Coverage PHPStan

  • Add php 8.2 to CI build
  • Docblocks update.

1.0.0

09 Jan 03:22
1.0.0
ab214bf
Compare
Choose a tag to compare

Stable release 馃帀 馃帀 馃帀

ci build Code Coverage PHPStan

A fast lookup library that help you verify and search array and Traversable data. It has the following features:

Features

鉁旓笍 Verify at least times: once(), twice(), times()
鉁旓笍 Verify exact times: once(), twice(), times()
鉁旓笍 Search data: first(), last()

Read the README.md for the usage :)

0.9.0

08 Jan 19:13
0.9.0
67a450c
Compare
Choose a tag to compare
  • Fix memory leak on Finder::last()

0.8.0

08 Jan 14:35
0.8.0
3a5e5ca
Compare
Choose a tag to compare
0.8.0