Completed
Push — master ( d970f9...8f8f7e )
by Petr
02:54
created

CommandResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
3
namespace Rottenwood\KingdomBundle\Command\Infrastructure;
4
5
class CommandResponse
6
{
7
8
    private $data;
9
    private $mapData;
10
    private $errors = [];
11
    private $commandName;
12
    private $waitstate;
13
14
    /**
15
     * @param string $commandName
16
     * @param array  $data
17
     * @param array  $mapData
18
     */
19
    public function __construct($commandName, array $data = [], array $mapData = [])
20
    {
21
        $this->data = $data;
22
        $this->mapData = $mapData;
23
        $this->commandName = $commandName;
24
    }
25
26
    /**
27
     * @param string $error
28
     */
29
    public function addError(string $error)
30
    {
31
        $this->errors[] = $error;
32
    }
33
34
    /**
35
     * @return array
36
     */
37
    public function getContents(): array
38
    {
39
        return array_filter(
40
            [
41
                'commandName' => $this->commandName,
42
                'data'        => $this->data,
43
                'mapData'     => $this->mapData,
44
                'waitstate'   => $this->waitstate,
45
                'errors'      => $this->errors,
46
            ]
47
        );
48
    }
49
50
    /**
51
     * @param array $data
52
     */
53
    public function setData(array $data)
54
    {
55
        $this->data = $data;
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    public function getMapData(): array
62
    {
63
        return $this->mapData;
64
    }
65
66
    /**
67
     * @param array $mapData
68
     */
69
    public function setMapData(array $mapData)
70
    {
71
        $this->mapData = $mapData;
72
    }
73
74
    /**
75
     * @param int $waitstate
76
     */
77
    public function setWaitstate(int $waitstate)
78
    {
79
        $this->waitstate = $waitstate;
80
    }
81
}
82