Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
33.33% |
2 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| IsActivatedUser | |
33.33% |
2 / 6 |
|
0.00% |
0 / 1 |
5.67 | |
0.00% |
0 / 1 |
| applies | |
33.33% |
2 / 6 |
|
0.00% |
0 / 1 |
5.67 | |||
| 1 | <?php |
| 2 | namespace Apie\Fixtures\Context; |
| 3 | |
| 4 | use Apie\Core\Attributes\ApieContextAttribute; |
| 5 | use Apie\Core\Context\ApieContext; |
| 6 | use Apie\Fixtures\Entities\UserWithAddress; |
| 7 | use Attribute; |
| 8 | |
| 9 | #[Attribute(Attribute::TARGET_METHOD)] |
| 10 | class IsActivatedUser implements ApieContextAttribute |
| 11 | { |
| 12 | public function applies(ApieContext $context): bool |
| 13 | { |
| 14 | if (!$context->hasContext('authenticated')) { |
| 15 | return false; |
| 16 | } |
| 17 | $user = $context->getContext('authenticated'); |
| 18 | if ($user instanceof UserWithAddress) { |
| 19 | return $user->hasPassword(); |
| 20 | } |
| 21 | |
| 22 | return false; |
| 23 | } |
| 24 | } |