Test Failed
Push — master ( ce60e5...378563 )
by Julien
12:41 queued 07:49
created

ServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 9
c 1
b 0
f 1
dl 0
loc 22
ccs 2
cts 8
cp 0.25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 18 1
1
<?php
2
3
/**
4
 * This file is part of the Zemit Framework.
5
 *
6
 * (c) Zemit Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zemit\Provider\Acl;
13
14
use Phalcon\Di\DiInterface;
15
use Zemit\Acl\Acl;
16
use Zemit\Config\ConfigInterface;
17
use Zemit\Provider\AbstractServiceProvider;
18
19
class ServiceProvider extends AbstractServiceProvider
20
{
21
    protected string $serviceName = 'acl';
22
    
23 23
    public function register(DiInterface $di): void
24
    {
25 23
        $di->setShared($this->getName(), function () use ($di) {
26
    
27
            // config
28
            $config = $di->get('config');
29
            assert($config instanceof ConfigInterface);
30
            
31
            // acl config
32
            $aclConfig = $config->pathToArray('acl') ?? [];
33
            
34
            // permissions config
35
            $permissionsConfig = $config->pathToArray('permissions') ?? [];
36
            
37
            // acl options
38
            $options = array_merge($aclConfig, ['permissions' => $permissionsConfig]);
39
            
40
            return new Acl($options);
41 23
        });
42
    }
43
}
44