Skip to content

2.6.0

Choose a tag to compare

@github-actions github-actions released this 22 Sep 06:08

New

I'm currently busy learning the amazing programming language Haskell and I backported into this library some stuff that I learned recently.

Breaking changes

There are 3 potential breaking changes in this release.

Compact

When compact was called without argument, the only value removed was null.

Starting of 2.6.0, when no argument is provided, it will remove all falsy values: null, false, 0, ''

Before:

$input = ['a', '', null, false, 0];

Collection::fromIterable($input)
    ->compact(); // ['a', '', false, 0]

After:

$input = ['a', '', null, false, 0];

Collection::fromIterable($input)
    ->compact(); // ['a']

Explode

Explode operation now mimic the PHP core function "explode" by removing the values used to explode the collection.

Before:

$input = range('a', 'j');

Collection::fromIterable($input)
    ->explode('b', 'd', 'f', 'h'); // ['a', ['b', 'c'], ['d', 'e'], ['f', 'g'], ['h', 'i', 'j']]

After:

$input = range('a', 'j');

Collection::fromIterable($input)
    ->explode('b', 'd', 'f', 'h'); // ['a', 'c', 'e', 'g', ['i', 'j']]

Split

The Split operation now has an extra integer parameter (a flag) that describe how the split should treat the value
which is used to split the collection into chunks.

  • Splitable::BEFORE: To insert that value at the beginning of the next chunk.
  • Splitable::AFTER: To insert that value at the end of the current chunk.
  • Splitable::REMOVE: To remove that value (the same as the explode operation)

Before:

$input = range('a', 'j');

Collection::fromIterable($input)
    ->split(static function ($value): bool {return $value === 'd';}

After:

$input = range('a', 'j');

Collection::fromIterable($input)
    ->split(
        Splitable::BEFORE, 
        static function ($value): bool {return $value === 'd';}
    )

Commits

  • Breaking change: refactor: Update Compact operation. 10fd55f
  • Breaking change: refactor: Update Explode operation. d28abcd
  • Breaking change: refactor: Update Split operation. 1c669b2
  • feat: Add fromFile static constructor. 7211052
  • feat: Add Words operation. 72df47a
  • feat: Add Unwords operation. b6aef32
  • feat: Add Unlines operation. ab9fde2
  • feat: Add Lines operation. 24cd4a5
  • refactor: Refactor operations using their parent operation counterpart. 0835f2d
  • refactor: Update Reverse operation. 6ce7b13
  • feat: Add scanLeft1 operation. 8b9aaa3
  • feat: Add scanRight1 operation. 1183407
  • feat: Add scanRight operation. c01274f
  • docs: Update FoldLeft and FoldRight. 98ced08
  • feat: Add scanLeft operation. ff0c7e4
  • docs: Update annotations. 317483e
  • feat: Add FoldRight1 operation. 18b9b1d
  • feat: Add FoldLeft1 operation. c034101
  • docs: Update README. ecdbc18
  • docs: Update documentation. 7985455
  • docs: Update API page. 516f786