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

tempestphp / tempest-framework / 14049246919

24 Mar 2025 09:42PM UTC coverage: 79.353% (-0.04%) from 79.391%
14049246919

push

github

web-flow
feat(support): support array parameters in string manipulations (#1073)

48 of 48 new or added lines in 2 files covered. (100.0%)

735 existing lines in 126 files now uncovered.

10492 of 13222 relevant lines covered (79.35%)

90.78 hits per line

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

31.03
/src/Tempest/EventBus/src/EventBusDiscovery.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\EventBus;
6

7
use BackedEnum;
8
use Tempest\Discovery\Discovery;
9
use Tempest\Discovery\DiscoveryLocation;
10
use Tempest\Discovery\IsDiscovery;
11
use Tempest\Reflection\ClassReflector;
12
use Tempest\Reflection\TypeReflector;
13
use UnitEnum;
14

15
final class EventBusDiscovery implements Discovery
16
{
17
    use IsDiscovery;
18

19
    public function __construct(
660✔
20
        private readonly EventBusConfig $eventBusConfig,
21
    ) {}
660✔
22

UNCOV
23
    public function discover(DiscoveryLocation $location, ClassReflector $class): void
×
24
    {
UNCOV
25
        foreach ($class->getPublicMethods() as $method) {
×
26
            $eventHandler = $method->getAttribute(EventHandler::class);
×
27

UNCOV
28
            if (! $eventHandler) {
×
29
                continue;
×
30
            }
31

UNCOV
32
            $eventName = match (true) {
×
33
                $eventHandler->event instanceof BackedEnum => $eventHandler->event->value,
×
34
                $eventHandler->event instanceof UnitEnum => $eventHandler->event->name,
×
35
                is_string($eventHandler->event) => $eventHandler->event,
×
36
                default => null,
×
37
            };
×
38

UNCOV
39
            if ($eventName === null) {
×
40
                $parameters = iterator_to_array($method->getParameters());
×
41

UNCOV
42
                if ($parameters === []) {
×
43
                    continue;
×
44
                }
45

46
                /** @var TypeReflector $type */
UNCOV
47
                $type = $parameters[0]->getType();
×
48

UNCOV
49
                if (! $type->isClass() && ! $type->isInterface()) {
×
50
                    continue;
×
51
                }
52

UNCOV
53
                $eventName = $type->getName();
×
54
            }
55

UNCOV
56
            $this->discoveryItems->add($location, [$eventName, $eventHandler, $method]);
×
57
        }
58
    }
59

60
    public function apply(): void
660✔
61
    {
62
        foreach ($this->discoveryItems as [$eventName, $eventHandler, $method]) {
660✔
63
            $this->eventBusConfig->addClassMethodHandler(
660✔
64
                event: $eventName,
660✔
65
                handler: $eventHandler,
660✔
66
                reflectionMethod: $method,
660✔
67
            );
660✔
68
        }
69
    }
70
}
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

© 2026 Coveralls, Inc