Passed
Push — 1.0 ( 1757a3...241f9e )
by Vladimir
02:41
created

ChannelServiceProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Channels\Providers;
6
7
use FondBot\Application\Config;
8
use FondBot\Channels\ChannelManager;
9
use League\Container\ServiceProvider\AbstractServiceProvider;
10
11
class ChannelServiceProvider extends AbstractServiceProvider
12
{
13
    protected $provides = [
14
        ChannelManager::class,
15
    ];
16
17
    /**
18
     * Use the register method to register items with the container via the
19
     * protected $this->container property or the `getContainer` method
20
     * from the ContainerAwareTrait.
21
     *
22
     * @return void
23
     */
24
    public function register(): void
25
    {
26
        /** @var Config $config */
27
        $config = $this->getContainer()->get(Config::class);
28
        /** @var array $channels */
29
        $channels = $config->get('channels', []);
30
31
        $manager = new ChannelManager;
32
33
        foreach ($channels as $name => $parameters) {
34
            $manager->add($name, $parameters);
35
        }
36
37
        $this->getContainer()->add(ChannelManager::class, $manager);
38
    }
39
}
40