Conditions | 4 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | 1 | protected function matchSimple(array &$models, Collection $results, $relation) |
|
27 | { |
||
28 | 1 | $dictionary = []; |
|
29 | |||
30 | 1 | foreach ($results as $result) { |
|
31 | 1 | $dictionary[ModelAccessor::get($result, 'laravel_through_key')][] = $result; |
|
32 | } |
||
33 | |||
34 | 1 | foreach ($models as &$model) { |
|
35 | 1 | $value = []; |
|
36 | |||
37 | 1 | if (isset($dictionary[$key = ModelAccessor::get($model, $this->parent->getKeyName())])) { |
|
38 | 1 | $value = $dictionary[$key]; |
|
39 | } |
||
40 | |||
41 | 1 | ModelAccessor::set($model, $relation, Collection::make($value)); |
|
42 | } |
||
43 | 1 | unset($model); |
|
44 | |||
45 | 1 | return $models; |
|
46 | } |
||
61 |