Passed
Push — 1.0 ( 12d132...dd1957 )
by Vladimir
06:10
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\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