Completed
Push — master ( 7ab9ab...b0b697 )
by Chauncey
12:29
created

AclAwareTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setAcl() 0 4 1
A acl() 0 11 2
1
<?php
2
3
namespace Charcoal\User;
4
5
use RuntimeException;
6
7
// From 'zendframework/zend-permissions-acl'
8
use Zend\Permissions\Acl\Acl;
9
10
/**
11
 * Provides access control list.
12
 */
13
trait AclAwareTrait
14
{
15
    /**
16
     * The ACL service.
17
     *
18
     * @var Acl
19
     */
20
    private $acl;
21
22
    /**
23
     * Set the Access Control List service.
24
     *
25
     * @param  Acl $acl The ACL service.
26
     * @return void
27
     */
28
    protected function setAcl(Acl $acl)
29
    {
30
        $this->acl = $acl;
31
    }
32
33
    /**
34
     * Retrieve the Access Control List service.
35
     *
36
     * @throws RuntimeException If the authenticator was not previously set.
37
     * @return Acl
38
     */
39
    protected function acl()
40
    {
41
        if (!$this->acl) {
42
            throw new RuntimeException(sprintf(
43
                'ACL service is not defined for "%s"',
44
                get_class($this)
45
            ));
46
        }
47
48
        return $this->acl;
49
    }
50
}
51