| Conditions | 6 |
| Paths | 1 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function contains($value, $index = null) |
||
| 32 | { |
||
| 33 | return (bool) $this->fold(function ($carry, $val, $key) use ($value, $index) { |
||
| 34 | if ($carry) { |
||
| 35 | return $carry; |
||
| 36 | } |
||
| 37 | if (is_callable($value)) { |
||
| 38 | $found = $value($val, $key); |
||
| 39 | } else { |
||
| 40 | $found = ($value == $val); |
||
| 41 | } |
||
| 42 | if ($found) { |
||
| 43 | if (is_null($index)) { |
||
| 44 | return true; |
||
| 45 | } |
||
| 46 | if (is_array($index)) { |
||
| 47 | return in_array($key, $index); |
||
| 48 | } |
||
| 49 | |||
| 50 | return $key == $index; |
||
| 51 | } |
||
| 52 | |||
| 53 | return false; |
||
| 54 | }); |
||
| 55 | } |
||
| 56 | |||
| 59 | } |