Test Failed
Push — develop ( 013d90...7b3751 )
by Nuno
03:38
created

AlgoliaEngine::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 7
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Scout Extended.
7
 *
8
 * (c) Algolia Team <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Algolia\ScoutExtended\Engines;
15
16
use Laravel\Scout\Builder;
17
use Algolia\ScoutExtended\Jobs\UpdateJob;
18
use Algolia\ScoutExtended\Jobs\DeleteJob;
19
use Algolia\AlgoliaSearch\Client as Algolia;
0 ignored issues
show
Bug introduced by
The type Algolia\AlgoliaSearch\Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Illuminate\Database\Eloquent\Collection;
21
use Algolia\ScoutExtended\Searchable\ModelsResolver;
22
use Algolia\ScoutExtended\Searchable\ObjectIdEncrypter;
23
use Laravel\Scout\Engines\AlgoliaEngine as BaseAlgoliaEngine;
24
25
class AlgoliaEngine extends BaseAlgoliaEngine
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function update($searchables)
31
    {
32
        dispatch_now(new UpdateJob($searchables));
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function delete($searchables)
39
    {
40
        dispatch_now(new DeleteJob($searchables));
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function map(Builder $builder, $results, $searchable)
47
    {
48
        if (count($results['hits']) === 0) {
49
            return Collection::make();
50
        }
51
52
        $ids = collect($results['hits'])->pluck('objectID')->values()->all();
53
54
        return resolve(ModelsResolver::class)->from($builder, $searchable, $ids);
55
    }
56
}
57