Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| BaseController | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| getPermissions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasPermission | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Engelsystem\Controllers; |
| 6 | |
| 7 | use Engelsystem\Http\Validation\ValidatesRequest; |
| 8 | use Psr\Http\Message\ServerRequestInterface; |
| 9 | |
| 10 | abstract class BaseController |
| 11 | { |
| 12 | use ValidatesRequest; |
| 13 | |
| 14 | /** @var string[]|string[][] A list of Permissions required to access the controller or certain pages */ |
| 15 | protected array $permissions = []; |
| 16 | |
| 17 | /** |
| 18 | * Returns the list of permissions for instance / methods |
| 19 | * |
| 20 | * @return string[]|string[][] |
| 21 | */ |
| 22 | public function getPermissions(): array |
| 23 | { |
| 24 | return $this->permissions; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Check if the request should be permitted |
| 29 | * |
| 30 | * $this->getPermissions will be interpreted on null return |
| 31 | */ |
| 32 | public function hasPermission(ServerRequestInterface $request, string $method): ?bool |
| 33 | { |
| 34 | return null; |
| 35 | } |
| 36 | } |