• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

phpolar / phpolar / 19429817281

17 Nov 2025 12:35PM UTC coverage: 88.983% (-11.0%) from 100.0%
19429817281

push

github

web-flow
508 rename abstractprotectedroutable to abstractrestrictedaccessrequestprocessor (#509)

* feat: rename to abstract restricted access request processor

The new name is more meaningful.

* docs: update project size threshold

Leaving the deprecated classes is causing the project size to increase.

26 of 28 new or added lines in 3 files covered. (92.86%)

24 existing lines in 2 files now uncovered.

210 of 236 relevant lines covered (88.98%)

5.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Auth/ProtectedRoutableResolver.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Phpolar\Phpolar\Auth;
6

7
use Deprecated;
8
use PhpContrib\Authenticator\AuthenticatorInterface;
9
use Phpolar\HttpRequestProcessor\RequestProcessorInterface;
10
use Phpolar\HttpRequestProcessor\RequestProcessorResolverInterface;
11
use ReflectionMethod;
12
use ReflectionAttribute;
13

14
/**
15
 * Returns either the given Routable or false when the user is not
16
 * authenticated.
17
 *
18
 * Authorization is *opt-in*.  Therefore, the given Routable
19
 * will be returned if it is not configured with
20
 * an Authorize attribute.
21
 *
22
 * @deprecated Use RestrictedAccessRequestProcessorResolver instead.
23
 */
24
final class ProtectedRoutableResolver implements RequestProcessorResolverInterface
25
{
26
    private const ROUTABLE_METHOD_NAME = "process";
27

28
    public function __construct(private readonly AuthenticatorInterface $authenticator) {}
29

30
    public function resolve(RequestProcessorInterface $target): RequestProcessorInterface | false
31
    {
NEW
32
        if ($target instanceof AbstractProtectedRoutable === false) {
×
UNCOV
33
            return $target;
×
34
        }
35

UNCOV
36
        $authenticateAttrs = $this->getAuthenticateAttributes($target);
×
UNCOV
37
        $isNotConfigured = empty($authenticateAttrs);
×
38

UNCOV
39
        if ($isNotConfigured === true) {
×
UNCOV
40
            return $target;
×
41
        }
42

UNCOV
43
        return $this->resolveRoutable(
×
UNCOV
44
            authenticateAttrs: $authenticateAttrs,
×
NEW
45
            target: $target,
×
UNCOV
46
        );
×
47
    }
48

49
    /**
50
     * @return ReflectionAttribute<Authorize>[]
51
     */
52
    private function getAuthenticateAttributes(RequestProcessorInterface $routable): array
53
    {
UNCOV
54
        $reflectionMethod = new ReflectionMethod($routable, self::ROUTABLE_METHOD_NAME);
×
UNCOV
55
        return $reflectionMethod->getAttributes(Authorize::class);
×
56
    }
57

58
    /**
59
     * @param ReflectionAttribute<Authorize>[] $authenticateAttrs
60
     */
61
    private function resolveRoutable(
62
        array $authenticateAttrs,
63
        AbstractProtectedRoutable $target,
64
    ): RequestProcessorInterface | false {
65
        /**
66
         * @var Authorize
67
         */
UNCOV
68
        $authenticateAttr = $authenticateAttrs[0]->newInstance();
×
UNCOV
69
        return $authenticateAttr->getResolvedRoutable(
×
UNCOV
70
            target: $target,
×
UNCOV
71
            authenticator: $this->authenticator,
×
UNCOV
72
        );
×
73
    }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc