Test Setup Failed
Pull Request — master (#48)
by Zing
11:23
created

QueryBuilderServiceProvider::boot()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.1406

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 15
ccs 6
cts 8
cp 0.75
crap 3.1406
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zing\QueryBuilder;
6
7
use Illuminate\Contracts\Support\DeferrableProvider;
8
use Illuminate\Foundation\Application as Laravel;
9
use Illuminate\Support\ServiceProvider;
10
use Laravel\Lumen\Application as Lumen;
0 ignored issues
show
Bug introduced by
The type Laravel\Lumen\Application 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...
11
12
class QueryBuilderServiceProvider extends ServiceProvider implements DeferrableProvider
13
{
14 35
    public function boot(): void
15
    {
16 35
        if (! $this->app->runningInConsole()) {
17
            return;
18
        }
19
20 35
        if (! $this->app instanceof Laravel) {
21
            return;
22
        }
23
24 35
        $this->publishes(
25
            [
26 35
                $this->getConfigPath() => config_path('query-builder.php'),
27
            ],
28 35
            'config'
29
        );
30 35
    }
31
32 35
    public function register(): void
33
    {
34 35
        $this->registerConfig();
35 35
        $this->app->singleton(
36 35
            QueryBuilderFactory::class,
37 35
            function () {
38 1
                return new QueryBuilderFactory(config('query-builder.builders'));
39 35
            }
40
        );
41 35
    }
42
43 35
    protected function getConfigPath(): string
44
    {
45 35
        return __DIR__ . '/../config/query-builder.php';
46
    }
47
48 35
    protected function registerConfig(): void
49
    {
50 35
        if ($this->app instanceof Lumen) {
51
            $this->app->configure('query-builder');
0 ignored issues
show
Bug introduced by
The method configure() does not exist on Illuminate\Contracts\Foundation\Application. Did you maybe mean configPath()? ( Ignorable by Annotation )

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

51
            $this->app->/** @scrutinizer ignore-call */ 
52
                        configure('query-builder');

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
        }
53
54 35
        $this->mergeConfigFrom($this->getConfigPath(), 'query-builder');
55 35
    }
56
57 1
    public function provides()
58
    {
59
        return [
60 1
            QueryBuilderFactory::class,
61
        ];
62
    }
63
}
64