| Conditions | 4 |
| Paths | 6 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 1 | protected function matchSimple(array &$models, Collection $results, $relation) |
|
| 25 | { |
||
| 26 | 1 | $dictionary = []; |
|
| 27 | |||
| 28 | 1 | $foreign = $this->getForeignKeyName(); |
|
| 29 | |||
| 30 | 1 | foreach ($results as $result) { |
|
| 31 | 1 | $dictionary[ModelAccessor::get($result, $foreign)][] = $result; |
|
| 32 | } |
||
| 33 | |||
| 34 | 1 | foreach ($models as &$model) { |
|
| 35 | 1 | $value = []; |
|
| 36 | |||
| 37 | 1 | if (isset($dictionary[$key = ModelAccessor::get($model, $this->localKey)])) { |
|
| 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 | } |
||
| 48 |