Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Requires | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
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 | * Add this attribute to tell ApieContext that it should only be called if a specific context is set. The value |
| 9 | * does not matter. |
| 10 | */ |
| 11 | #[Attribute(Attribute::IS_REPEATABLE|Attribute::TARGET_CLASS|Attribute::TARGET_METHOD|Attribute::TARGET_PROPERTY|Attribute::TARGET_PARAMETER|Attribute::TARGET_CLASS_CONSTANT)] |
| 12 | final class Requires implements ApieContextAttribute |
| 13 | { |
| 14 | public function __construct(public string $instance) |
| 15 | { |
| 16 | } |
| 17 | |
| 18 | public function applies(ApieContext $context): bool |
| 19 | { |
| 20 | return $context->hasContext($this->instance); |
| 21 | } |
| 22 | } |