CsFixerServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 5
eloc 14
dl 0
loc 41
ccs 16
cts 18
cp 0.8889
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 14 1
A boot() 0 2 1
A setupConfig() 0 9 3
1
<?php
2
3
namespace Noitran\CsFixer;
4
5
use Illuminate\Support\ServiceProvider;
6
use Noitran\CsFixer\Console\PhpCsCommand;
7
use Noitran\CsFixer\Console\HookSetupCommand;
8
use Laravel\Lumen\Application as LumenApplication;
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...
9
use Illuminate\Foundation\Application as LaravelApplication;
10
11
/**
12
 * Class CsFixerServiceProvider
13
 */
14
class CsFixerServiceProvider extends ServiceProvider
15
{
16
    /**
17
     * Bootstrap the application services.
18
     */
19 1
    public function boot(): void
20
    {
21
        //
22 1
    }
23
24
    /**
25
     * Register the application services.
26
     */
27 1
    public function register(): void
28
    {
29 1
        $this->setupConfig();
30
31
        $this->app->singleton('command.phpcs.fix', function () {
32 1
            return new PhpCsCommand();
33 1
        });
34
35
        $this->app->singleton('command.phpcs.install-hook', function () {
36 1
            return new HookSetupCommand();
37 1
        });
38
39 1
        $this->commands('command.phpcs.fix');
40 1
        $this->commands('command.phpcs.install-hook');
41 1
    }
42
43
    /**
44
     * @return void
45
     */
46 1
    protected function setupConfig(): void
47
    {
48 1
        $source = \dirname(__DIR__) . '/config/phpcs.php';
49 1
        if ($this->app instanceof LaravelApplication) {
50 1
            $this->publishes([$source => config_path('phpcs.php')]);
51
        } elseif ($this->app instanceof LumenApplication) {
52
            $this->app->configure('phpcs');
0 ignored issues
show
Bug introduced by
The method configure() does not exist on Illuminate\Contracts\Foundation\Application. ( 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->app->/** @scrutinizer ignore-call */ 
53
                        configure('phpcs');

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
        }
54 1
        $this->mergeConfigFrom($source, 'phpcs');
55 1
    }
56
}
57