| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function __call($type, $arguments) |
||
| 13 | { |
||
| 14 | $id = $arguments[0]; |
||
| 15 | |||
| 16 | if ($id instanceof \Model) { |
||
| 17 | return $id; |
||
| 18 | } |
||
| 19 | |||
| 20 | $class = new \ReflectionClass("\\" . ucfirst($type)); |
||
| 21 | |||
| 22 | if (!$class->isSubclassOf("\\Model")) { |
||
| 23 | throw new \Exception("$type is not a model"); |
||
| 24 | } |
||
| 25 | |||
| 26 | return $class->getMethod('get') |
||
| 27 | ->invoke(null, $id); |
||
| 28 | } |
||
| 29 | } |
||
| 30 |