Total Complexity | 9 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
25 | class Authorities extends AbstractProvider implements ValidationInterface |
||
26 | { |
||
27 | /** |
||
28 | * Authorities::validate |
||
29 | * |
||
30 | * Checks if the object is a valid instance. |
||
31 | * |
||
32 | * @param object $object The object to be validated. |
||
33 | * |
||
34 | * @return bool Returns TRUE on valid or FALSE on failure. |
||
35 | */ |
||
36 | public function validate($object) |
||
37 | { |
||
38 | if ($object instanceof Authority) { |
||
39 | return true; |
||
40 | } |
||
41 | |||
42 | return false; |
||
43 | } |
||
44 | |||
45 | public function authorize($segments) |
||
46 | { |
||
47 | if ($authority = $this->getAuthority($segments)) { |
||
48 | return $authority->getPermission() === 'GRANTED' ? true : false; |
||
49 | } |
||
50 | |||
51 | return false; |
||
52 | } |
||
53 | |||
54 | public function getAuthority($segments) |
||
65 | } |
||
66 | } |