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

ChannelServiceProvider::register()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 0
cts 6
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
crap 6
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