Conditions | 5 |
Paths | 7 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
20 | 61 | public function fill(array $data, array $forbidden = []): void |
|
21 | { |
||
22 | 61 | foreach ($forbidden as $item) { |
|
23 | 17 | if (isset($data[$item])) { |
|
24 | 1 | throw new BadArgumentException( |
|
25 | 1 | \sprintf('Argument %s is forbidden in %s constructor', $item, static::class) |
|
26 | ); |
||
27 | } |
||
28 | } |
||
29 | 60 | foreach ($data as $key => $value) { |
|
30 | 60 | if (!\property_exists($this, $key)) { |
|
31 | 1 | throw new BadArgumentException(\sprintf('Argument %s not found in %s', $key, static::class)); |
|
32 | } |
||
33 | 59 | $this->{$key} = $value; |
|
34 | } |
||
37 |