Passed
Push — master ( ce1ae9...e9c52d )
by Mr
08:10
created

ServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace EasyRSA\Laravel;
4
5
use EasyRSA\Worker;
6
use Illuminate\Contracts\Container\Container;
7
use Illuminate\Foundation\Application as LaravelApplication;
8
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
9
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...
10
11
class ServiceProvider extends BaseServiceProvider
12
{
13
    /**
14
     * Bootstrap any application services.
15
     *
16
     * @return void
17
     */
18
    public function boot(): void
19
    {
20
        $this->setUpConfig();
21
    }
22
23
    /**
24
     * Register any application services.
25
     *
26
     * @return void
27
     */
28
    public function register(): void
29
    {
30
        $app = $this->app;
31
32
        $app->singleton('easy-rsa.factory', static function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

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

32
        $app->singleton('easy-rsa.factory', static function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
33
            return new Factory();
34
        });
35
36
        $app->singleton('easy-rsa', static function ($app) {
37
            return new Manager($app, $app['easy-rsa.factory']);
38
        });
39
40
        $app->alias('easy-rsa', Manager::class);
41
42
        $app->singleton(Worker::class, static function (Container $app) {
43
            return $app->make('easy-rsa')->connection();
0 ignored issues
show
Bug introduced by
The method connection() does not exist on EasyRSA\Laravel\Manager. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

43
            return $app->make('easy-rsa')->/** @scrutinizer ignore-call */ connection();
Loading history...
44
        });
45
    }
46
47
    protected function setUpConfig(): void
48
    {
49
        $source = dirname(__DIR__) . '/config/easy-rsa.php';
50
51
        if ($this->app instanceof LaravelApplication) {
52
            $this->publishes([$source => config_path('easy-rsa.php')], 'config');
53
        } elseif ($this->app instanceof LumenApplication) {
54
            $this->app->configure('easy-rsa');
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

54
            $this->app->/** @scrutinizer ignore-call */ 
55
                        configure('easy-rsa');

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...
55
        }
56
57
        $this->mergeConfigFrom($source, 'easy-rsa');
58
    }
59
}
60