Skip to content

Releases: samsonasik/ArrayLookup

Released: ArrayLookup 1.8.1

01 Nov 10:49
1.8.1
c26a928
Compare
Choose a tag to compare

What's Changed

  • Fix Psalm Crash by Removing Equals Sign in @ param Annotations by @nynka in #26

New Contributors

  • @nynka made their first contribution in #26

Full Changelog: 1.8.0...1.8.1

Released: ArrayLookup 1.8.0

07 Sep 16:39
1.8.0
1f4027d
Compare
Choose a tag to compare

1.8.0

ci build Code Coverage PHPStan

Allow optional when on Collector class, just transform, no filter.

$data = [
    ' a ',
    ' b ',
    ' c ',
];

transformed trim new data with:

use ArrayLookup\Collector;

$transform = fn (string $datum): string => trim($datum);

$newArray = Collector::setUp($data)
       ->withTransform($transform)
       ->getResults(); // ['a', 'b', 'c']

Released: ArrayLookup 1.7.0

07 Sep 13:36
1.7.0
d3c90d4
Compare
Choose a tag to compare

1.7.0

ci build Code Coverage PHPStan

Add new Collector class, for collect filtered data, with new transformed each data found, for example, we have data:

$data = [
    ' a ',
    ' b ',
    ' c ',
    new \stdClass(),
];

we need to collect new data into new array with transformed no space in results.

Before

$newArray = [];

foreach ($data as $datum) {
    if (is_string($datum)) {
        $newArray[] = trim($datum);
    }
}

After, with Collector class

use ArrayLookup\Collector;


$when = fn (mixed $datum): bool => is_string($datum);
$limit = 2;
$transform = fn (string $datum): string => trim($datum);

$newArray = Collector::setUp($data)
       ->when($when)
       ->withLimit(2) // optional to only collect some data provided by limit config
       ->withTransform($transform)
       ->getResults(); // ['a', 'b', 'c']

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.