Passed
Push — master ( 4a2c07...a97be8 )
by Zing
04:39
created

QueryBuilderServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 85%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 36
ccs 17
cts 20
cp 0.85
rs 10
c 1
b 0
f 0
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A registerConfig() 0 7 2
A boot() 0 15 3
A getConfigPath() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zing\QueryBuilder;
6
7
use Illuminate\Foundation\Application as Laravel;
8
use Illuminate\Support\ServiceProvider;
9
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...
10
11
class QueryBuilderServiceProvider extends ServiceProvider
12
{
13 46
    public function boot(): void
14
    {
15 46
        QueryConfiguration::setPerPage((int) config('query-builder.per_page.default'));
16 46
        QueryConfiguration::setPageName((string) config('query-builder.per_page.key'));
17 46
        if (! $this->app->runningInConsole()) {
18
            return;
19
        }
20
21 46
        if (! $this->app instanceof Laravel) {
22
            return;
23
        }
24
25 46
        $this->publishes([
26 46
            $this->getConfigPath() => config_path('query-builder.php'),
27 46
        ], 'config');
28 46
    }
29
30 46
    public function register(): void
31
    {
32 46
        $this->registerConfig();
33 46
    }
34
35 46
    protected function getConfigPath(): string
36
    {
37 46
        return __DIR__ . '/../config/query-builder.php';
38
    }
39
40 46
    protected function registerConfig(): void
41
    {
42 46
        if ($this->app instanceof Lumen) {
43
            $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

43
            $this->app->/** @scrutinizer ignore-call */ 
44
                        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...
44
        }
45
46 46
        $this->mergeConfigFrom($this->getConfigPath(), 'query-builder');
47 46
    }
48
}
49