Completed
Push — master ( fde887...02d242 )
by Petr
03:30
created

CommandResponse::setWaitstate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

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