| Conditions | 6 |
| Paths | 5 |
| Total Lines | 14 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | 6 | public function run(array $args) |
|
| 12 | { |
||
| 13 | 6 | if (!isset($args[0])) { |
|
| 14 | 1 | throw new ArgumentException('"if" expects first argument condition.'); |
|
| 15 | 5 | } else if (!isset($args[1])) { |
|
| 16 | 1 | throw new ArgumentException('"if" expects second argument body.'); |
|
| 17 | } |
||
| 18 | 4 | $condition = $this->eval->getReturn($args[0])->value(); |
|
| 19 | 4 | if ($condition !== null && $condition !== false) { |
|
| 20 | 3 | return $this->eval->getReturn($args[1]); |
|
| 21 | } else { |
||
| 22 | 3 | return isset($args[2]) ? $this->eval->getReturn($args[2]) : $this->newReturnType('Nil'); |
|
| 23 | } |
||
| 24 | } |
||
| 25 | } |
||
| 26 |