Conditions | 3 |
Paths | 2 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function testReduceIterativelyReducesCollectionToASingleValue() |
||
21 | { |
||
22 | $coll = Factory::create($this->fixtures['names']); |
||
23 | |||
24 | $count = function ($carry, $val, $key = null) { |
||
25 | return ++$carry; |
||
26 | }; |
||
27 | |||
28 | $concat = function ($carry, $val, $key = null) { |
||
29 | return $carry.$val; |
||
30 | }; |
||
31 | |||
32 | $concateven = function ($carry, $val, $key) { |
||
33 | if ($key % 2 == 0) { |
||
34 | $carry .= $val; |
||
35 | } |
||
36 | |||
37 | return $carry; |
||
38 | }; |
||
39 | |||
40 | $this->assertEquals(10, $coll->reduce($count)); |
||
41 | $this->assertEquals('ChelseaAdellaMonteMayeLottieDonDaytonKirkTroyNakia', $coll->reduce($concat)); |
||
42 | |||
43 | if (!$coll instanceof \Novactive\Tests\Perfs\ArrayMethodCollection) { |
||
44 | $this->assertEquals('ChelseaMonteLottieDaytonTroy', $coll->reduce($concateven)); |
||
45 | } |
||
46 | } |
||
47 | } |
||
48 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.