| Conditions | 7 |
| Paths | 6 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 7.0222 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 4 | public function run(ModelsCommand $command, Model $model): void |
|
| 20 | { |
||
| 21 | 4 | $traits = class_uses_recursive($model); |
|
| 22 | |||
| 23 | 4 | if (!in_array(HasMergedRelationships::class, $traits)) { |
|
| 24 | return; |
||
| 25 | } |
||
| 26 | |||
| 27 | 4 | $methods = (new ReflectionClass($model))->getMethods(ReflectionMethod::IS_PUBLIC); |
|
| 28 | |||
| 29 | 4 | foreach ($methods as $method) { |
|
| 30 | 4 | if ($method->isStatic() || $method->getNumberOfParameters() > 0) { |
|
| 31 | 4 | continue; |
|
| 32 | } |
||
| 33 | |||
| 34 | try { |
||
| 35 | 4 | $relationship = $method->invoke($model); |
|
| 36 | 1 | } catch (Throwable) { |
|
| 37 | 1 | continue; |
|
| 38 | } |
||
| 39 | |||
| 40 | 4 | if ($relationship instanceof MergedRelation) { |
|
| 41 | 4 | $this->addRelationship($command, $method, $relationship); |
|
| 42 | } |
||
| 67 |