Passed
Pull Request — master (#38)
by Zing
10:07 queued 06:18
created

QueryBuilderServiceProvider::getConfigPath()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
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() && $this->app instanceof Laravel) {
17 35
            $this->publishes(
18
                [
19 35
                    $this->getConfigPath() => config_path('query-builder.php'),
20
                ],
21 35
                'config'
22
            );
23
        }
24 35
    }
25
26 35
    public function register(): void
27
    {
28 35
        $this->registerConfig();
29 35
        $this->app->singleton(
30 35
            QueryBuilderFactory::class,
31
            function () {
32 1
                return new QueryBuilderFactory(config('query-builder.builders'));
33 35
            }
34
        );
35 35
    }
36
37 35
    protected function getConfigPath(): string
38
    {
39 35
        return __DIR__ . '/../config/query-builder.php';
40
    }
41
42 35
    protected function registerConfig(): void
43
    {
44 35
        if ($this->app instanceof Lumen) {
45
            $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

45
            $this->app->/** @scrutinizer ignore-call */ 
46
                        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...
46
        }
47
48 35
        $this->mergeConfigFrom($this->getConfigPath(), 'query-builder');
49 35
    }
50
51 1
    public function provides()
52
    {
53
        return [
54 1
            QueryBuilderFactory::class,
55
        ];
56
    }
57
}
58