AclResourceModule::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 4
crap 1
1
<?php
2
/**
3
 * This file is part of the BEAR.AclResourceModule package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\AclResourceModule;
8
9
use BEAR\Resource\ResourceObject;
10
use Ray\Di\AbstractModule;
11
use Ray\RoleModule\RoleProviderInterface;
12
use Zend\Permissions\Acl\AclInterface;
13
14
class AclResourceModule extends AbstractModule
15
{
16
    /**
17
     * @var array
18
     */
19
    private $resources;
20
21
    /**
22
     * @var AclInterface
23
     */
24
    private $acl;
25
26
    /**
27
     * @var string
28
     */
29
    private $roleProvider;
30
31 4
    public function __construct(AclInterface $acl, array $resources, string $roleProvider, AbstractModule $module = null)
32
    {
33 4
        $this->resources = $resources;
34 4
        $this->acl = $acl;
35 4
        $this->roleProvider = $roleProvider;
36 4
        parent::__construct($module);
37 4
    }
38
39 4
    protected function configure()
40
    {
41 4
        $this->bind(AclInterface::class)->toInstance($this->acl);
42 4
        $this->bind(RoleProviderInterface::class)->to(FakeRoleProvider::class);
43 4
        $this->bind()->annotatedWith('resources')->toInstance($this->resources);
44 4
        $this->bindInterceptor(
45 4
            $this->matcher->subclassesOf(ResourceObject::class),
46 4
            $this->matcher->startsWith('onGet'),
47 4
            [AclEmbedInterceptor::class]
48
        );
49 4
    }
50
}
51