| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | 86 | public function setOptions(array $options, $ignoreMissingOptions = false) |
|
| 24 | { |
||
| 25 | 86 | foreach ($options as $option => $value) { |
|
| 26 | 82 | $setter = 'set' . ucfirst($option); |
|
| 27 | |||
| 28 | 82 | if (method_exists($this, $setter)) { |
|
| 29 | 78 | $this->$setter($value); |
|
| 30 | 78 | continue; |
|
| 31 | } |
||
| 32 | |||
| 33 | 6 | if (property_exists($this, $option)) { |
|
| 34 | 4 | $this->$option = $value; |
|
| 35 | 4 | continue; |
|
| 36 | } |
||
| 37 | |||
| 38 | 2 | if (!$ignoreMissingOptions) { |
|
| 39 | 1 | throw new InvalidArgumentException( |
|
| 40 | 1 | "Property `{$option}` not found in class `" . __CLASS__ . "`." |
|
| 41 | 1 | ); |
|
| 42 | } |
||
| 43 | 85 | } |
|
| 44 | 85 | } |
|
| 45 | } |
||
| 46 |