Set::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 1
crap 2
1
<?php
2
namespace Desmond\functions\core;
3
use Desmond\functions\DesmondFunction;
4
use Desmond\ArgumentHelper;
5
use Desmond\exceptions\ArgumentException;
6
7
class Set extends DesmondFunction
8
{
9
    use ArgumentHelper;
10
11 334
    public function id()
12
    {
13 334
        return 'set';
14
    }
15
16 5
    public function run(array $args)
17
    {
18 5
        $args = $this->cloneArgs($args);
19 5
        $this->expectArguments(
20 5
            'set',
21 5
            [0 => ['Hash'], 1 => ['Number', 'Symbol', 'String']],
22 5
            $args
23
        );
24 3
        if (!isset($args[2])) {
25 1
            throw new ArgumentException('"set" expects third argument.');
26
        }
27 2
        $newHash = $args[0];
28 2
        $newHash->set($args[2], $args[1]->value());
29 2
        return $newHash;
30
    }
31
}
32