Total Complexity | 5 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | abstract class AbstractStateAssistant |
||
11 | { |
||
12 | /** @var Manager */ |
||
13 | protected $manager; |
||
14 | |||
15 | /** @var StatefulContract $model */ |
||
16 | protected $model; |
||
17 | |||
18 | public function manager(Manager $manager) |
||
19 | { |
||
20 | $this->manager = $manager; |
||
21 | $this->model = $manager->model(); |
||
22 | |||
23 | if(!$this->model instanceof StatefulContract){ |
||
24 | throw new \InvalidArgumentException(static::class . ' requires the model to implement the ' . StatefulContract::class); |
||
25 | } |
||
26 | } |
||
27 | |||
28 | abstract public static function key(): string; |
||
29 | |||
30 | abstract public function route($verb): ?string; |
||
31 | |||
32 | public function can($verb): bool |
||
33 | { |
||
34 | return !is_null($this->route($verb)); |
||
35 | } |
||
36 | |||
37 | public function guard($verb): Assistant |
||
44 | } |
||
45 | } |
||
46 |