Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| AccessRule | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| isGrant | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRole | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getMask | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\tao\model\accessControl\func; |
| 23 | |
| 24 | use core_kernel_classes_Resource; |
| 25 | |
| 26 | /** |
| 27 | * An access rule gramnting or denying access to a functionality |
| 28 | * |
| 29 | * @access public |
| 30 | * @author Joel Bout, <joel@taotesting.com> |
| 31 | * @package tao |
| 32 | */ |
| 33 | class AccessRule |
| 34 | { |
| 35 | public const GRANT = 'grant'; |
| 36 | public const DENY = 'deny'; |
| 37 | |
| 38 | private $grantDeny; |
| 39 | |
| 40 | private $role; |
| 41 | |
| 42 | private $mask; |
| 43 | |
| 44 | |
| 45 | public function __construct($mode, $roleUri, $mask) |
| 46 | { |
| 47 | $this->grantDeny = $mode; |
| 48 | $this->role = new core_kernel_classes_Resource($roleUri); |
| 49 | $this->mask = $mask; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Those the role grant you access? |
| 54 | * @return bool |
| 55 | */ |
| 56 | public function isGrant() |
| 57 | { |
| 58 | return $this->grantDeny == self::GRANT; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Gets the role this rule applies to |
| 63 | * @return core_kernel_classes_Resource |
| 64 | */ |
| 65 | public function getRole() |
| 66 | { |
| 67 | return $this->role; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Returns the filter of the rule |
| 72 | * @return array |
| 73 | */ |
| 74 | public function getMask() |
| 75 | { |
| 76 | return $this->mask; |
| 77 | } |
| 78 | } |