| Conditions | 4 |
| Paths | 6 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4.016 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 1 | public function getOr($default) |
|
| 34 | { |
||
| 35 | 1 | if (is_callable($this->predicate)) { |
|
| 36 | 1 | $p = $this->predicate; |
|
| 37 | } else { |
||
| 38 | $p = function ($r) { |
||
| 39 | 1 | return is_null($r); |
|
| 40 | 1 | }; |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | if (! $p($this->result)) { |
|
| 44 | 1 | return $this->result; |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | if (is_callable($default)) { |
|
| 48 | return call_user_func($default); |
||
| 49 | } |
||
| 50 | |||
| 51 | 1 | return $default; |
|
| 52 | } |
||
| 53 | |||
| 80 | } |