Test Failed
Pull Request — master (#159)
by
unknown
13:31
created

ScoutElasticSearchServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 88.24%

Importance

Changes 6
Bugs 1 Features 0
Metric Value
eloc 13
c 6
b 1
f 0
dl 0
loc 39
ccs 15
cts 17
cp 0.8824
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 1
A register() 0 6 1
A registerCommands() 0 7 3
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 37
    public function boot(): void
23
    {
24 37
        $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 37
        resolve(EngineManager::class)->extend(ElasticSearchEngine::class, function () {
27 7
            $elasticsearch = resolve(Client::class);
28
29 7
            return new ElasticSearchEngine($elasticsearch);
30 37
        });
31 37
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 37
    public function register(): void
37
    {
38 37
        $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 37
        $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 37
        $this->registerCommands();
42 37
    }
43
44
    /**
45
     * Register artisan commands.
46
     *
47
     * @return void
48
     */
49 37
    private function registerCommands(): void
50
    {
51 37
        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 37
            if (config('scout.driver') === 'Matchish\ScoutElasticSearch\Engines\ElasticSearchEngine') {
53
                $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

53
                $this->/** @scrutinizer ignore-call */ 
54
                       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...
54
                    ImportCommand::class,
55
                    FlushCommand::class,
56
                ]);
57
            }
58
        }
59 37
    }
60
}
61