| @@ 7-26 (lines=20) @@ | ||
| 4 | ||
| 5 | use Igni\Utils\Exception\ReflectionApiException; |
|
| 6 | ||
| 7 | trait AbstractTrait |
|
| 8 | { |
|
| 9 | private $abstract = false; |
|
| 10 | ||
| 11 | public function makeAbstract(bool $abstract = true): self |
|
| 12 | { |
|
| 13 | if (isset($this->final) && $this->final) { |
|
| 14 | throw ReflectionApiException::forFinalAbstract(); |
|
| 15 | } |
|
| 16 | ||
| 17 | $this->abstract = $abstract; |
|
| 18 | ||
| 19 | return $this; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function isAbstract(): bool |
|
| 23 | { |
|
| 24 | return $this->abstract; |
|
| 25 | } |
|
| 26 | } |
|
| 27 | ||
| @@ 7-26 (lines=20) @@ | ||
| 4 | ||
| 5 | use Igni\Utils\Exception\ReflectionApiException; |
|
| 6 | ||
| 7 | trait FinalTrait |
|
| 8 | { |
|
| 9 | private $final = false; |
|
| 10 | ||
| 11 | public function makeFinal(bool $final = true): self |
|
| 12 | { |
|
| 13 | if (isset($this->abstract) && $this->abstract) { |
|
| 14 | throw ReflectionApiException::forFinalAbstract(); |
|
| 15 | } |
|
| 16 | ||
| 17 | $this->final = $final; |
|
| 18 | ||
| 19 | return $this; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function isFinal(): bool |
|
| 23 | { |
|
| 24 | return $this->final; |
|
| 25 | } |
|
| 26 | } |
|
| 27 | ||