Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
33.33% covered (danger)
33.33%
2 / 6
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
IsActivatedUser
33.33% covered (danger)
33.33%
2 / 6
0.00% covered (danger)
0.00%
0 / 1
5.67
0.00% covered (danger)
0.00%
0 / 1
 applies
33.33% covered (danger)
33.33%
2 / 6
0.00% covered (danger)
0.00%
0 / 1
5.67
1<?php
2namespace Apie\Fixtures\Context;
3
4use Apie\Core\Attributes\ApieContextAttribute;
5use Apie\Core\Context\ApieContext;
6use Apie\Fixtures\Entities\UserWithAddress;
7use Attribute;
8
9#[Attribute(Attribute::TARGET_METHOD)]
10class 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}