This repository has been archived on 2020-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
2018-08-07 16:43:09 +00:00
|
|
|
--TEST--
|
|
|
|
Test Collection::reduce() and Collection::reduceRight().
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
$collection = Collection::init(['a', 'b', 'c', 'd', 'e']);
|
|
|
|
$reduce_cb = function ($acc, $value, $key) {
|
|
|
|
return $acc.$value.strval($key);
|
|
|
|
};
|
2018-08-28 14:11:09 +00:00
|
|
|
if ($collection->reduce($reduce_cb) != 'ab1c2d3e4') {
|
2018-08-07 16:43:09 +00:00
|
|
|
echo 'Collection::reduce() failed.', PHP_EOL;
|
2018-08-28 14:11:09 +00:00
|
|
|
}
|
|
|
|
if ($collection->reduceRight($reduce_cb) != 'ed3c2b1a0') {
|
2018-08-07 16:43:09 +00:00
|
|
|
echo 'Collection::reduceRight() failed.', PHP_EOL;
|
2018-08-28 14:11:09 +00:00
|
|
|
}
|
2018-08-07 16:43:09 +00:00
|
|
|
?>
|
|
|
|
--EXPECT--
|