| Conditions | 6 |
| Paths | 11 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 9.3798 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | 2 | public function fill(array $data, array $forbidden = [], NameConverterInterface $converter = null) |
|
| 23 | { |
||
| 24 | 2 | foreach ($forbidden as $item) { |
|
| 25 | if (isset($data[$item])) { |
||
| 26 | throw new BadArgumentException( |
||
| 27 | \sprintf('Argument %s is forbidden in %s constructor', $item, static::class) |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | 2 | foreach ($data as $key => $value) { |
|
| 32 | 2 | if ($converter) { |
|
| 33 | $key = $converter->denormalize($key); |
||
| 34 | } |
||
| 35 | 2 | if (!\property_exists($this, $key)) { |
|
| 36 | throw new BadArgumentException(\sprintf('Argument %s not found in %s', $key, static::class)); |
||
| 37 | } |
||
| 38 | 2 | $this->{$key} = $value; |
|
| 39 | } |
||
| 42 |