Set   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 25
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A id() 0 4 1
A run() 0 15 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