| Conditions | 3 |
| Paths | 8 |
| Total Lines | 14 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public static function factory(string $name, string $xml): ModelInterface |
||
| 19 | { |
||
| 20 | try { |
||
| 21 | $name = $name == 'kases' ? 'case' : $name; |
||
| 22 | $className = sprintf( |
||
| 23 | '%s\%sModel', |
||
| 24 | __NAMESPACE__, |
||
| 25 | ucfirst(strtolower($name)) |
||
| 26 | ); |
||
| 27 | $reflectionClass = new \ReflectionClass($className); |
||
| 28 | return $reflectionClass->newInstance($xml); |
||
| 29 | } catch (\ReflectionException $ex) { |
||
| 30 | throw new InvalidModelException( |
||
| 31 | sprintf('The %s model does not exist.', $name) |
||
| 32 | ); |
||
| 36 |