Passed
Push — master ( eb87b7...6a4b39 )
by Fabien
02:24
created

BeforeAnalysisChannel::getEventClassname()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Churn\Event\Channel;
6
7
use Churn\Event\Channel;
8
use Churn\Event\Event\BeforeAnalysis as BeforeAnalysisEvent;
9
use Churn\Event\Subscriber\BeforeAnalysis;
10
use Closure;
11
12
/**
13
 * @internal
14
 * @implements Channel<BeforeAnalysis, BeforeAnalysisEvent>
15
 */
16
final class BeforeAnalysisChannel implements Channel
17
{
18
    /**
19
     * @param object $subscriber A subscriber instance.
20
     */
21
    public function accepts($subscriber): bool
22
    {
23
        return $subscriber instanceof BeforeAnalysis;
24
    }
25
26
    /**
27
     * @return class-string<BeforeAnalysisEvent>
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<BeforeAnalysisEvent> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<BeforeAnalysisEvent>.
Loading history...
28
     */
29
    public function getEventClassname(): string
30
    {
31
        return BeforeAnalysisEvent::class;
32
    }
33
34
    /**
35
     * @param object $subscriber A subscriber instance.
36
     * @return Closure(BeforeAnalysisEvent): void
37
     * @psalm-param BeforeAnalysis $subscriber
38
     */
39
    public function buildEventHandler($subscriber): Closure
40
    {
41
        return static function (BeforeAnalysisEvent $event) use ($subscriber): void {
42
            $subscriber->onBeforeAnalysis($event);
43
        };
44
    }
45
}
46