Passed
Push — 1.0 ( 12d132...dd1957 )
by Vladimir
06:10
created

ChannelServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 31
ccs 0
cts 9
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A register() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Channels\Providers;
6
7
use FondBot\Channels\ChannelManager;
8
use League\Container\ServiceProvider\AbstractServiceProvider;
9
10
class ChannelServiceProvider extends AbstractServiceProvider
11
{
12
    protected $provides = [
13
        ChannelManager::class,
14
    ];
15
16
    private $channels;
17
18
    public function __construct(array $channels)
19
    {
20
        $this->channels = $channels;
21
    }
22
23
    /**
24
     * Use the register method to register items with the container via the
25
     * protected $this->container property or the `getContainer` method
26
     * from the ContainerAwareTrait.
27
     *
28
     * @return void
29
     */
30
    public function register(): void
31
    {
32
        $manager = new ChannelManager;
33
34
        foreach ($this->channels as $name => $parameters) {
35
            $manager->add($name, $parameters);
36
        }
37
38
        $this->getContainer()->add(ChannelManager::class, $manager);
39
    }
40
}
41