ClassEventDiscriminator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldEnqueue() 0 3 1
A __construct() 0 3 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 ClassEventDiscriminator implements EventDiscriminator
19
{
20
    /**
21
     * @var string
22
     */
23
    private $class;
24
25
    /**
26
     * ClassEventDiscriminator constructor.
27
     *
28
     * @param string $class
29
     */
30
    public function __construct(string $class)
31
    {
32
        $this->class = $class;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function shouldEnqueue(Event $event): bool
39
    {
40
        return \is_a($event, $this->class);
41
    }
42
}
43