| Conditions | 7 |
| Paths | 6 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 12 | public function relationships() |
||
| 13 | { |
||
| 14 | $model = new static; |
||
| 15 | |||
| 16 | $relationships = []; |
||
| 17 | |||
| 18 | foreach ((new ReflectionClass($model))->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { |
||
| 19 | if ($method->class != get_class($model) || |
||
| 20 | ! empty($method->getParameters()) || |
||
| 21 | $method->getName() == __FUNCTION__) { |
||
| 22 | continue; |
||
| 23 | } |
||
| 24 | |||
| 25 | try { |
||
| 26 | $return = $method->invoke($model); |
||
| 27 | |||
| 28 | if ($return instanceof Relation) { |
||
| 29 | $relationships[$method->getName()] = [ |
||
| 30 | 'type' => (new ReflectionClass($return))->getShortName(), |
||
| 31 | 'model' => (new ReflectionClass($return->getRelated()))->getName(), |
||
| 32 | ]; |
||
| 33 | } |
||
| 34 | } catch (ErrorException $e) { |
||
|
|
|||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | return $relationships; |
||
| 39 | } |
||
| 41 |