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

68publishers / smart-nette-component / 3671567024

pending completion
3671567024

Pull #3

github

GitHub
Merge 8c2bf16fd into d93ee51a5
Pull Request #3: WIP: v1

389 of 389 new or added lines in 24 files covered. (100.0%)

408 of 419 relevant lines covered (97.37%)

0.97 hits per line

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

90.91
/src/Authorization/Handler/HandlerRegistry.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace SixtyEightPublishers\SmartNetteComponent\Authorization\Handler;
6

7
use InvalidArgumentException;
8
use SixtyEightPublishers\SmartNetteComponent\Authorization\RuleInterface;
9
use SixtyEightPublishers\SmartNetteComponent\Authorization\RuleHandlerInterface;
10
use function sprintf;
11
use function get_class;
12

13
final class HandlerRegistry implements RuleHandlerInterface
14
{
15
        /**
16
         * @param array<RuleHandlerInterface> $handlers
17
         */
18
        public function __construct(
1✔
19
                private readonly array $handlers
20
        ) {
21
        }
1✔
22

23
        public function canHandle(RuleInterface $rule): bool
24
        {
25
                return true;
×
26
        }
27

28
        public function __invoke(RuleInterface $rule): void
1✔
29
        {
30
                foreach ($this->handlers as $handler) {
1✔
31
                        if ($handler->canHandle($rule)) {
1✔
32
                                $handler($rule);
1✔
33

34
                                return;
1✔
35
                        }
36
                }
37

38
                throw new InvalidArgumentException(sprintf(
1✔
39
                        'Can\'t handle rule of type %s.',
1✔
40
                        get_class($rule)
1✔
41
                ));
42
        }
43
}
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