Passed
Pull Request — master (#129)
by Serhii
13:55
created

ScoutElasticSearchServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Matchish\ScoutElasticSearch;
6
7
use Elasticsearch\Client;
8
use Illuminate\Support\ServiceProvider;
9
use Laravel\Scout\EngineManager;
10
use Laravel\Scout\ScoutServiceProvider;
11
use Matchish\ScoutElasticSearch\Console\Commands\FlushCommand;
12
use Matchish\ScoutElasticSearch\Console\Commands\ImportCommand;
13
use Matchish\ScoutElasticSearch\Engines\ElasticSearchEngine;
14
use Matchish\ScoutElasticSearch\Searchable\DefaultImportSourceFactory;
15
use Matchish\ScoutElasticSearch\Searchable\ImportSourceFactory;
16
17
final class ScoutElasticSearchServiceProvider extends ServiceProvider
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 48
    public function boot(): void
23
    {
24 48
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'scout');
0 ignored issues
show
Bug introduced by
The method loadTranslationsFrom() does not exist on Matchish\ScoutElasticSea...icSearchServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        $this->/** @scrutinizer ignore-call */ 
25
               loadTranslationsFrom(__DIR__.'/../resources/lang', 'scout');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
26 48
        resolve(EngineManager::class)->extend(ElasticSearchEngine::class, function () {
27 18
            $elasticsearch = resolve(Client::class);
28
29 18
            return new ElasticSearchEngine($elasticsearch);
30 48
        });
31 48
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 48
    public function register(): void
37
    {
38 48
        $this->app->register(ScoutServiceProvider::class);
0 ignored issues
show
Unused Code introduced by
The call to Tests\Laravel\App::register() has too many arguments starting with Laravel\Scout\ScoutServiceProvider::class. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        $this->app->/** @scrutinizer ignore-call */ 
39
                    register(ScoutServiceProvider::class);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
39 48
        $this->app->bind(ImportSourceFactory::class, DefaultImportSourceFactory::class);
0 ignored issues
show
Bug introduced by
The method bind() does not exist on Tests\Laravel\App. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        $this->app->/** @scrutinizer ignore-call */ 
40
                    bind(ImportSourceFactory::class, DefaultImportSourceFactory::class);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
41 48
        $this->registerCommands();
42 48
    }
43
44
    /**
45
     * Register artisan commands.
46
     *
47
     * @return void
48
     */
49 48
    private function registerCommands(): void
50
    {
51 48
        if ($this->app->runningInConsole()) {
0 ignored issues
show
Bug introduced by
The method runningInConsole() does not exist on Tests\Laravel\App. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        if ($this->app->/** @scrutinizer ignore-call */ runningInConsole()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52 48
            $this->commands([
0 ignored issues
show
Bug introduced by
The method commands() does not exist on Matchish\ScoutElasticSea...icSearchServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
            $this->/** @scrutinizer ignore-call */ 
53
                   commands([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53 48
                ImportCommand::class,
54
                FlushCommand::class,
55
            ]);
56
        }
57 48
    }
58
}
59