ProviderRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A load() 0 6 2
A createProvider() 0 4 1
1
<?php
2
3
namespace Magister\Services\Foundation;
4
5
use Magister\Magister;
6
7
/**
8
 * Class ProviderRepository.
9
 */
10
class ProviderRepository
11
{
12
    /**
13
     * The application implementation.
14
     *
15
     * @var \Magister\Magister
16
     */
17
    protected $app;
18
19
    /**
20
     * Create a new provider repository instance.
21
     *
22
     * @param \Magister\Magister $app
23
     */
24
    public function __construct(Magister $app)
25
    {
26
        $this->app = $app;
27
    }
28
29
    /**
30
     * Register the application service providers.
31
     *
32
     * @param array $providers
33
     *
34
     * @return void
35
     */
36
    public function load(array $providers)
37
    {
38
        foreach ($providers as $provider) {
39
            $this->app->register($this->createProvider($provider));
40
        }
41
    }
42
43
    /**
44
     * Create a new provider instance.
45
     *
46
     * @param string $provider
47
     *
48
     * @return \Magister\Services\Support\ServiceProvider
49
     */
50
    public function createProvider($provider)
51
    {
52
        return new $provider($this->app);
53
    }
54
}
55