| 1 | <?php |
||
| 8 | class Permission |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Check permission. |
||
| 12 | * |
||
| 13 | * @param $permission |
||
| 14 | * |
||
| 15 | * @return true |
||
| 16 | */ |
||
| 17 | public static function check($permission) |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Roles allowed to access. |
||
| 30 | * |
||
| 31 | * @param $roles |
||
| 32 | * |
||
| 33 | * @return true |
||
| 34 | */ |
||
| 35 | public static function allow($roles) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Roles denied to access. |
||
| 48 | * |
||
| 49 | * @param $roles |
||
| 50 | * |
||
| 51 | * @return true |
||
| 52 | */ |
||
| 53 | public static function deny($roles) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Send error response page. |
||
| 66 | */ |
||
| 67 | protected static function error() |
||
| 76 | |||
| 77 | /** |
||
| 78 | * If current user is administrator. |
||
| 79 | * |
||
| 80 | * @return mixed |
||
| 81 | */ |
||
| 82 | public static function isAdministrator() |
||
| 86 | } |
||
| 87 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exitexpression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.