Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RequiresAuthenticatedUser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 applies
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\IntegrationTests\Apie\TypeDemo\Rules;
3
4use Apie\Core\Attributes\ApieContextAttribute;
5use Apie\Core\Context\ApieContext;
6use Apie\Core\ContextConstants;
7use Attribute;
8
9/**
10 * Runtime check that only allows the action if a user is logged in. Used to verify
11 * that an authorization failure (ActionNotAllowedException) results in a 401/403
12 * HTTP response instead of a 500 (see ErrorRenderTest).
13 */
14#[Attribute(Attribute::TARGET_METHOD)]
15class RequiresAuthenticatedUser implements ApieContextAttribute
16{
17    public function applies(ApieContext $context): bool
18    {
19        return (bool) $context->getContext(ContextConstants::AUTHENTICATED_USER, false);
20    }
21}