Completed
Push — master ( aafddc...deb7e5 )
by Julián
01:18
created

ArrayCommandDiscriminator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A shouldEnqueue() 0 4 1
1
<?php
2
3
/*
4
 * cqrs-async (https://github.com/phpgears/cqrs-async).
5
 * Async decorator for CQRS command bus.
6
 *
7
 * @license MIT
8
 * @link https://github.com/phpgears/cqrs-async
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace Gears\CQRS\Async\Discriminator;
15
16
use Gears\CQRS\Command;
17
18
final class ArrayCommandDiscriminator implements CommandDiscriminator
19
{
20
    /**
21
     * @var string[]
22
     */
23
    private $commands;
24
25
    /**
26
     * ArrayCommandDiscriminator constructor.
27
     *
28
     * @param string[] $commands
29
     */
30
    public function __construct(array $commands)
31
    {
32
        $this->commands = \array_values($commands);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function shouldEnqueue(Command $command): bool
39
    {
40
        return \in_array(\get_class($command), $this->commands, true);
41
    }
42
}
43