Passed
Push — master ( a24d5d...5d2fe9 )
by Julien
05:02
created

ServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 9
c 1
b 0
f 1
dl 0
loc 22
ccs 8
cts 8
cp 1
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 46
    public function register(DiInterface $di): void
24
    {
25 46
        $di->setShared($this->getName(), function () use ($di) {
26
    
27
            // config
28 1
            $config = $di->get('config');
29 1
            assert($config instanceof ConfigInterface);
30
            
31
            // acl config
32 1
            $aclConfig = $config->pathToArray('acl', []);
33
            
34
            // permissions config
35 1
            $permissionsConfig = $config->pathToArray('permissions', []);
36
            
37
            // acl options
38 1
            $options = array_merge($aclConfig, ['permissions' => $permissionsConfig]);
0 ignored issues
show
Bug introduced by
It seems like $aclConfig can also be of type null; however, parameter $arrays of array_merge() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
            $options = array_merge(/** @scrutinizer ignore-type */ $aclConfig, ['permissions' => $permissionsConfig]);
Loading history...
39
            
40 1
            return new Acl($options);
41 46
        });
42
    }
43
}
44