Conditions | 7 |
Paths | 6 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 7.0178 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | 43 | public function set($nameOrArray, $value = null) |
|
8 | { |
||
9 | 43 | if (is_array($nameOrArray)) { |
|
10 | 12 | foreach ($nameOrArray as $k => $v) { |
|
11 | 12 | $this->set($k, $v); |
|
12 | 12 | } |
|
13 | |||
14 | 12 | return; |
|
15 | } |
||
16 | 43 | if (!is_string($nameOrArray)) { |
|
17 | throw new \InvalidArgumentException('Only strings or arrays are accepted as first argument of the set() method of the DataContainer class'); |
||
18 | } |
||
19 | 43 | if ($value !== null) { |
|
20 | 43 | $this[$nameOrArray] = $value; |
|
21 | 43 | } elseif ($value === null && isset($this[$nameOrArray])) { |
|
22 | 3 | unset($this[$nameOrArray]); |
|
23 | 3 | } |
|
24 | 43 | } |
|
25 | |||
37 | } |