Completed
Push — master ( 16939b...cf6c6d )
by Julián
01:17
created

ArrayEventDiscriminator::shouldEnqueue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * event-async (https://github.com/phpgears/event-async).
5
 * Async decorator for Event bus.
6
 *
7
 * @license MIT
8
 * @link https://github.com/phpgears/event-async
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace Gears\Event\Async\Discriminator;
15
16
use Gears\Event\Event;
17
18
final class ArrayEventDiscriminator implements EventDiscriminator
19
{
20
    /**
21
     * @var string[]
22
     */
23
    private $events;
24
25
    /**
26
     * ArrayEventDiscriminator constructor.
27
     *
28
     * @param string[] $events
29
     */
30
    public function __construct(array $events)
31
    {
32
        $this->events = \array_values($events);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function shouldEnqueue(Event $event): bool
39
    {
40
        return \in_array(\get_class($event), $this->events, true);
41
    }
42
}
43