| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | 14 | public function run(array $args) |
|
| 12 | { |
||
| 13 | 14 | $this->expectArguments('let', [['Hash']], $args); |
|
| 14 | 13 | if (!isset($args[1])) { |
|
| 15 | 1 | throw new ArgumentException('"let" expects a second argument.'); |
|
| 16 | } |
||
| 17 | 12 | $hash = $args[0]; |
|
| 18 | 12 | $function = $args[1]; |
|
| 19 | 12 | $newEnvId = $this->currentEnv->makeChild(); |
|
| 20 | |||
| 21 | 12 | $this->currentEnv = $this->currentEnv->values[$newEnvId]; |
|
| 22 | 12 | foreach ($hash->value() as $key => $val) { |
|
| 23 | 12 | $this->currentEnv->set($key, $this->eval->getReturn($val)); |
|
| 24 | } |
||
| 25 | 12 | $funcVal = $this->eval->getReturn($function); |
|
| 26 | |||
| 27 | 12 | $this->currentEnv = $this->currentEnv->getParent(); |
|
| 28 | 12 | $this->currentEnv->destroyChild($newEnvId); |
|
| 29 | 12 | return $funcVal; |
|
| 30 | } |
||
| 31 | } |
||
| 32 |