Test Failed
Push — develop ( 63ed01...7218b8 )
by Nuno
05:28
created

AlgoliaEngine::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\AlgoliaSearch\Client;
18
use Algolia\ScoutExtended\Jobs\DeleteJob;
19
use Algolia\ScoutExtended\Jobs\UpdateJob;
20
use Illuminate\Database\Eloquent\Collection;
21
use Algolia\ScoutExtended\Searchable\ModelsResolver;
22
use Laravel\Scout\Engines\AlgoliaEngine as BaseAlgoliaEngine;
23
24
class AlgoliaEngine extends BaseAlgoliaEngine
25
{
26
    /**
27
     * @param \Algolia\AlgoliaSearch\Client $algolia
28
     */
29 20
    public function setClient(Client $algolia): void
30
    {
31 20
        $this->algolia = $algolia;
0 ignored issues
show
Documentation Bug introduced by
It seems like $algolia of type Algolia\AlgoliaSearch\Client is incompatible with the declared type AlgoliaSearch\Client of property $algolia.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
32 20
    }
33
    /**
34
     * {@inheritdoc}
35
     */
36 12
    public function update($searchables)
37
    {
38 12
        dispatch_now(new UpdateJob($searchables));
39 12
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 5
    public function delete($searchables)
45
    {
46 5
        dispatch_now(new DeleteJob($searchables));
47 5
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 4
    public function map(Builder $builder, $results, $searchable)
53
    {
54 4
        if (count($results['hits']) === 0) {
55 2
            return Collection::make();
56
        }
57
58 2
        $ids = collect($results['hits'])->pluck('objectID')->values()->all();
59
60 2
        return resolve(ModelsResolver::class)->from($builder, $searchable, $ids);
61
    }
62
}
63