| Conditions | 3 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public function map(Builder $builder, $results, $model): Collection |
||
| 26 | { |
||
| 27 | if (count($results['hits']) === 0) { |
||
| 28 | return collect(); |
||
| 29 | } |
||
| 30 | |||
| 31 | $models = $model->getScoutModelsByIds( |
||
| 32 | $builder, collect($results['hits'])->pluck('objectID')->values()->all() |
||
| 33 | )->keyBy(function ($model) { |
||
| 34 | return $model->getScoutKey(); |
||
| 35 | })->map->getModel(); |
||
| 36 | |||
| 37 | return collect($results['hits'])->map(function ($hit) use ($models) { |
||
| 38 | if (isset($models[$hit['objectID']])) { |
||
| 39 | return $models[$hit['objectID']]; |
||
| 40 | } |
||
| 41 | })->filter()->values(); |
||
| 42 | } |
||
| 44 |