Kernel   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 60
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0
wmc 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A bootstrapping() 0 3 1
A loadCoreServiceProvider() 0 8 4
A loadConfiguration() 0 3 1
A getStorage() 0 3 1
A loadServiceProvider() 0 5 2
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Cart;
5
6
use Cart\Contracts\CartDriverContract;
7
use Cart\Contracts\ServiceProviderContract;
8
use Cart\Contracts\SourceConfiguration;
9
use Illuminate\Container\Container;
10
use Illuminate\Config\Repository;
11
use Symfony\Component\Finder\Finder;
12
13
/**
14
 * Class Kernel
15
 *
16
 * @package Cart
17
 */
18
class Kernel
19
{
20
    /**
21
     * @var Container
22
     */
23
    protected $app;
24
25
    protected $coreServices = [
26
        'config.singleton' => Repository::class,
27
    ];
28
29 5
    public function __construct()
30
    {
31 5
        $this->app = Container::getInstance();
32 5
    }
33
34 3
    public function bootstrapping() : void
35
    {
36 3
        $this->loadCoreServiceProvider();
37 3
    }
38
39
    /**
40
     * Get type storage (Note: in config file)
41
     */
42 1
    public function getStorage() : CartDriverContract
43
    {
44 1
        return $this->app->make(config('cart.storage'));
45
    }
46
47
    /**
48
     * Get all of the configuration files for the application.
49
     * @param SourceConfiguration $configuration
50
     */
51 1
    public function loadConfiguration(SourceConfiguration $configuration) :  void
52
    {
53 1
        config()->set($configuration->getName(), $configuration->get());
0 ignored issues
show
Bug introduced by
The method set() does not exist on Illuminate\Container\Container. ( Ignorable by Annotation )

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

53
        config()->/** @scrutinizer ignore-call */ set($configuration->getName(), $configuration->get());

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...
54 1
    }
55
56
    /**
57
     * Load service provider from config file
58
     */
59 1
    public function loadServiceProvider() : void
60
    {
61 1
        foreach (config('cart.services') as $services) {
62
            /** @var ServiceProviderContract */
63 1
            (new $services)->register($this->app);
64
        }
65 1
    }
66
67
    /**
68
     * Load mandatory services for application
69
     */
70 3
    protected function loadCoreServiceProvider() : void
71
    {
72 3
        foreach ($this->coreServices as $abstract => $service) {
73 3
            list($abstract, $type) = explode('.', $abstract);
74
75 3
            if (app()->resolved($abstract) === false) {
76 1
                if ($type == 'singleton') {
77 1
                    $this->app->singleton($abstract, $service);
78
                }
79
            }
80
        }
81 3
    }
82
}
83