Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| RemovalCheck | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isStaticCheck | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isRuntimeCheck | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| applies | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\Attributes; |
| 3 | |
| 4 | use Apie\Core\Context\ApieContext; |
| 5 | use Attribute; |
| 6 | |
| 7 | /** |
| 8 | * By default resources can not be removed. This attribute needs to be defined before it can be removed. |
| 9 | */ |
| 10 | #[Attribute(Attribute::IS_REPEATABLE|Attribute::TARGET_CLASS)] |
| 11 | final class RemovalCheck |
| 12 | { |
| 13 | private StaticCheck|RuntimeCheck $check; |
| 14 | |
| 15 | public function __construct(StaticCheck|RuntimeCheck $check) |
| 16 | { |
| 17 | $this->check = $check; |
| 18 | } |
| 19 | |
| 20 | public function isStaticCheck(): bool |
| 21 | { |
| 22 | return $this->check instanceof StaticCheck; |
| 23 | } |
| 24 | |
| 25 | public function isRuntimeCheck(): bool |
| 26 | { |
| 27 | return $this->check instanceof RuntimeCheck; |
| 28 | } |
| 29 | |
| 30 | public function applies(ApieContext $context): bool |
| 31 | { |
| 32 | return $this->check->applies($context); |
| 33 | } |
| 34 | } |