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

ArrayCommandDiscriminator::__construct()   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
 * 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