ServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 49
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A register() 0 18 1
A setUpConfig() 0 12 3
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;
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 () {
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();
44
        });
45
    }
46
47
    protected function setUpConfig(): void
48
    {
49
        $source = __DIR__ . '/../../config/easy-rsa.php';
50
51
        if ($this->app instanceof LaravelApplication) {
0 ignored issues
show
Bug introduced by
The class Illuminate\Foundation\Application does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
52
            $this->publishes([$source => config_path('easy-rsa.php')], 'config');
53
        } elseif ($this->app instanceof LumenApplication) {
0 ignored issues
show
Bug introduced by
The class Laravel\Lumen\Application does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
54
            $this->app->configure('easy-rsa');
55
        }
56
57
        $this->mergeConfigFrom($source, 'easy-rsa');
58
    }
59
}
60