| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * @author enea dhack <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Enea\Authorization\Blade; |
||
| 13 | |||
| 14 | use Enea\Authorization\Contracts\Authorizable; |
||
| 15 | use Enea\Authorization\Facades\Helper; |
||
| 16 | |||
| 17 | abstract class CheckableDirective |
||
| 18 | { |
||
| 19 | abstract public function name(): string; |
||
| 20 | |||
| 21 | abstract protected function check(Authorizable $authorizable, string $grantable): bool; |
||
| 22 | |||
| 23 | 4 | public function isAuthorized(string $grantable, ?string $guard = null): bool |
|
| 24 | { |
||
| 25 | 4 | $authenticated = Helper::authenticated($guard); |
|
| 26 | 4 | return $authenticated !== null ? $this->check($authenticated, $grantable) : false; |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 27 | } |
||
| 28 | } |
||
| 29 |