ArrayCommandDiscriminator::__construct()   A
last analyzed

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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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 $commandTypes;
24
25
    /**
26
     * ArrayCommandDiscriminator constructor.
27
     *
28
     * @param string[] $commandTypes
29
     */
30
    public function __construct(array $commandTypes)
31
    {
32
        $this->commandTypes = \array_values($commandTypes);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function shouldEnqueue(Command $command): bool
39
    {
40
        return \in_array($command->getCommandType(), $this->commandTypes, true);
41
    }
42
}
43