| Conditions | 9 |
| Paths | 6 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 9 |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | 21 | public function configure(array $config = []) |
|
| 8 | { |
||
| 9 | 21 | if (is_array($config) && array_key_exists('filename', $config)) { |
|
| 10 | 18 | $config['filepath'] = isset($config['filepath']) && is_string($config['filepath']) ? $config['filepath'] : '.'; |
|
| 11 | 18 | $config['filepath'] .= '/'; |
|
| 12 | 18 | $config['filepath'] .= isset($config['filename']) && is_string($config['filename']) ? $config['filename'] : 'sprite.png'; |
|
| 13 | 18 | unset($config['filename']); |
|
| 14 | 18 | } |
|
| 15 | |||
| 16 | 21 | foreach ($config as $key => $value) { |
|
| 17 | 21 | if (!property_exists($this, $key)) { |
|
| 18 | 3 | throw new \Exception('Undefined configuration property "'.$key.'"'); |
|
| 19 | } |
||
| 20 | 18 | $this->$key = $value; |
|
| 21 | 18 | } |
|
| 22 | |||
| 23 | 18 | return $this; |
|
| 24 | } |
||
| 25 | } |
||
| 26 |