AbstractCommandQueue::__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;
15
16
use Gears\CQRS\Async\Serializer\CommandSerializer;
17
use Gears\CQRS\Command;
18
19
abstract class AbstractCommandQueue implements CommandQueue
20
{
21
    /**
22
     * Command serializer.
23
     *
24
     * @var CommandSerializer
25
     */
26
    private $serializer;
27
28
    /**
29
     * AbstractCommandQueue constructor.
30
     *
31
     * @param CommandSerializer $serializer
32
     */
33
    public function __construct(CommandSerializer $serializer)
34
    {
35
        $this->serializer = $serializer;
36
    }
37
38
    /**
39
     * Get serialized command.
40
     *
41
     * @param Command $command
42
     *
43
     * @return string
44
     */
45
    final protected function getSerializedCommand(Command $command): string
46
    {
47
        return $this->serializer->serialize($command);
48
    }
49
}
50