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

AclAwareTrait::acl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 0
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