| Conditions | 5 |
| Paths | 5 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 28 | public function setOptions(array $options, $ignoreMissingOptions = false) |
|
| 18 | { |
||
| 19 | 28 | foreach ($options as $option => $value) { |
|
| 20 | 3 | $setter = 'set' . ucfirst($option); |
|
| 21 | |||
| 22 | 3 | if (method_exists($this, $setter)) { |
|
| 23 | 1 | $this->$setter($value); |
|
| 24 | 1 | continue; |
|
| 25 | } |
||
| 26 | |||
| 27 | 2 | if (property_exists($this, $option)) { |
|
| 28 | 1 | $this->$option = $value; |
|
| 29 | 1 | continue; |
|
| 30 | } |
||
| 31 | |||
| 32 | 1 | if (!$ignoreMissingOptions) { |
|
| 33 | 1 | throw new InvalidArgumentException("Property `{$option}` not found in class `" . __CLASS__ . "`."); |
|
| 34 | } |
||
| 35 | 27 | } |
|
| 36 | 27 | } |
|
| 37 | } |
||
| 38 |