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

AfterFileAnalysisChannel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildEventHandler() 0 4 1
A getEventClassname() 0 3 1
A accepts() 0 3 1
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\AfterFileAnalysis as AfterFileAnalysisEvent;
9
use Churn\Event\Subscriber\AfterFileAnalysis;
10
use Closure;
11
12
/**
13
 * @internal
14
 * @implements Channel<AfterFileAnalysis, AfterFileAnalysisEvent>
15
 */
16
final class AfterFileAnalysisChannel implements Channel
17
{
18
    /**
19
     * @param object $subscriber A subscriber instance.
20
     */
21
    public function accepts($subscriber): bool
22
    {
23
        return $subscriber instanceof AfterFileAnalysis;
24
    }
25
26
    /**
27
     * @return class-string<AfterFileAnalysisEvent>
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<AfterFileAnalysisEvent> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<AfterFileAnalysisEvent>.
Loading history...
28
     */
29
    public function getEventClassname(): string
30
    {
31
        return AfterFileAnalysisEvent::class;
32
    }
33
34
    /**
35
     * @param object $subscriber A subscriber instance.
36
     * @return Closure(AfterFileAnalysisEvent): void
37
     * @psalm-param AfterFileAnalysis $subscriber
38
     */
39
    public function buildEventHandler($subscriber): Closure
40
    {
41
        return static function (AfterFileAnalysisEvent $event) use ($subscriber): void {
42
            $subscriber->onAfterFileAnalysis($event);
43
        };
44
    }
45
}
46