Passed
Push — master ( 321509...140bc5 )
by Agaletskiy
02:43
created

FacadeDocListV2Query   A

Complexity

Total Complexity 31

Size/Duplication

Total Lines 241
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 31
lcom 1
cbo 0
dl 0
loc 241
rs 9.92
c 0
b 0
f 0

28 Methods

Rating   Name   Duplication   Size   Complexity  
A getDateFrom() 0 4 1
A setDateFrom() 0 4 1
A getDateTo() 0 4 1
A setDateTo() 0 4 1
A getNumber() 0 4 1
A setNumber() 0 4 1
A getDocumentStatus() 0 4 1
A setDocumentStatus() 0 4 1
A getDocumentType() 0 4 1
A setDocumentType() 0 4 1
A getInputFormat() 0 4 1
A setInputFormat() 0 4 1
A getParticipantInn() 0 4 1
A setParticipantInn() 0 4 1
A getOrder() 0 4 1
A setOrder() 0 4 1
A getDid() 0 4 1
A setDid() 0 4 1
A getOrderedColumnValue() 0 4 1
A setOrderedColumnValue() 0 4 1
A getOrderColumn() 0 4 1
A setOrderColumn() 0 4 1
A getPageDir() 0 4 1
A setPageDir() 0 4 1
A getLimit() 0 4 1
A setLimit() 0 4 1
A toQueryArray() 0 26 2
A appendIfNotNull() 0 6 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\IsmpClient\V3\Dto;
6
7
final class FacadeDocListV2Query
8
{
9
    public const DOCUMENT_STATUS_IN_PROGRESS = 'IN_PROGRESS';
10
    public const DOCUMENT_STATUS_CHECKED_OK = 'CHECKED_OK';
11
    public const DOCUMENT_STATUS_CHECKED_NOT_OK = 'CHECKED_NOT_OK';
12
    public const DOCUMENT_STATUS_PROCESSING_ERROR = 'PROCESSING_ERROR';
13
    public const DOCUMENT_STATUS_UNDEFINED = 'UNDEFINED';
14
15
    public const DOCUMENT_TYPE_LP_INTRODUCE_GOODS = 'LP_INTRODUCE_GOODS';
16
    public const DOCUMENT_TYPE_LP_INTRODUCE_GOODS_CSV = 'LP_INTRODUCE_GOODS_CSV';
17
    public const DOCUMENT_TYPE_LP_INTRODUCE_GOODS_XML = 'LP_INTRODUCE_GOODS_XML';
18
    public const DOCUMENT_TYPE_LP_SHIP_GOODS = 'LP_SHIP_GOODS';
19
    public const DOCUMENT_TYPE_LP_SHIP_GOODS_XML = 'LP_SHIP_GOODS_XML';
20
    public const DOCUMENT_TYPE_LP_ACCEPT_GOODS = 'LP_ACCEPT_GOODS';
21
    public const DOCUMENT_TYPE_LP_ACCEPT_GOODS_XML = 'LP_ACCEPT_GOODS_XML';
22
23
    public const ORDER_ASC = 'ASC';
24
    public const ORDER_DESC = 'DESC';
25
26
    public const ORDER_COLUMN_DOC_DATE = 'docDate';
27
28
    public const PAGE_DIR_NEXT = 'NEXT';
29
    public const PAGE_DIR_PREV = 'PREV';
30
31
    /**
32
     * @var \DateTimeInterface | null
33
     */
34
    private $dateFrom;
35
    /**
36
     * @var \DateTimeInterface | null
37
     */
38
    private $dateTo;
39
    /**
40
     * @var string | null
41
     */
42
    private $number;
43
    /**
44
     * @var string | null
45
     */
46
    private $documentStatus;
47
    /**
48
     * @var string | null
49
     */
50
    private $documentType;
51
    /**
52
     * @var bool | null
53
     */
54
    private $inputFormat;
55
    /**
56
     * @var string | null
57
     */
58
    private $participantInn;
59
    /**
60
     * @var string | null
61
     */
62
    private $order;
63
    /**
64
     * @var string | null
65
     */
66
    private $did;
67
    /**
68
     * @var string | null
69
     */
70
    private $orderedColumnValue;
71
    /**
72
     * @var string | null
73
     */
74
    private $orderColumn;
75
    /**
76
     * @var string | null
77
     */
78
    private $pageDir;
79
    /**
80
     * @var int
81
     */
82
    private $limit = 10;
83
84
    public function getDateFrom(): ?\DateTimeInterface
85
    {
86
        return $this->dateFrom;
87
    }
88
89
    public function setDateFrom(?\DateTimeInterface $dateFrom): void
90
    {
91
        $this->dateFrom = $dateFrom;
92
    }
93
94
    public function getDateTo(): ?\DateTimeInterface
95
    {
96
        return $this->dateTo;
97
    }
98
99
    public function setDateTo(?\DateTimeInterface $dateTo): void
100
    {
101
        $this->dateTo = $dateTo;
102
    }
103
104
    public function getNumber(): ?string
105
    {
106
        return $this->number;
107
    }
108
109
    public function setNumber(?string $number): void
110
    {
111
        $this->number = $number;
112
    }
113
114
    public function getDocumentStatus(): ?string
115
    {
116
        return $this->documentStatus;
117
    }
118
119
    public function setDocumentStatus(?string $documentStatus): void
120
    {
121
        $this->documentStatus = $documentStatus;
122
    }
123
124
    public function getDocumentType(): ?string
125
    {
126
        return $this->documentType;
127
    }
128
129
    public function setDocumentType(?string $documentType): void
130
    {
131
        $this->documentType = $documentType;
132
    }
133
134
    public function getInputFormat(): ?bool
135
    {
136
        return $this->inputFormat;
137
    }
138
139
    public function setInputFormat(?bool $inputFormat): void
140
    {
141
        $this->inputFormat = $inputFormat;
142
    }
143
144
    public function getParticipantInn(): ?string
145
    {
146
        return $this->participantInn;
147
    }
148
149
    public function setParticipantInn(?string $participantInn): void
150
    {
151
        $this->participantInn = $participantInn;
152
    }
153
154
    public function getOrder(): ?string
155
    {
156
        return $this->order;
157
    }
158
159
    public function setOrder(?string $order): void
160
    {
161
        $this->order = $order;
162
    }
163
164
    public function getDid(): ?string
165
    {
166
        return $this->did;
167
    }
168
169
    public function setDid(?string $did): void
170
    {
171
        $this->did = $did;
172
    }
173
174
    public function getOrderedColumnValue(): ?string
175
    {
176
        return $this->orderedColumnValue;
177
    }
178
179
    public function setOrderedColumnValue(?string $orderedColumnValue): void
180
    {
181
        $this->orderedColumnValue = $orderedColumnValue;
182
    }
183
184
    public function getOrderColumn(): ?string
185
    {
186
        return $this->orderColumn;
187
    }
188
189
    public function setOrderColumn(?string $orderColumn): void
190
    {
191
        $this->orderColumn = $orderColumn;
192
    }
193
194
    public function getPageDir(): ?string
195
    {
196
        return $this->pageDir;
197
    }
198
199
    public function setPageDir(?string $pageDir): void
200
    {
201
        $this->pageDir = $pageDir;
202
    }
203
204
    public function getLimit(): int
205
    {
206
        return $this->limit;
207
    }
208
209
    public function setLimit(int $limit): void
210
    {
211
        $this->limit = $limit;
212
    }
213
214
    public function toQueryArray(): array
215
    {
216
        $query = [];
217
218
        self::appendIfNotNull($query, 'dateTo', $this->dateTo, static function (\DateTimeInterface $value) {
219
            return $value->format('H');
220
        });
221
        self::appendIfNotNull($query, 'dateFrom', $this->dateFrom, static function (\DateTimeInterface $value) {
222
            return $value->format('H');
223
        });
224
        self::appendIfNotNull($query, 'number', $this->number);
225
        self::appendIfNotNull($query, 'documentStatus', $this->documentStatus);
226
        self::appendIfNotNull($query, 'documentType', $this->documentType);
227
        self::appendIfNotNull($query, 'inputFormat', $this->inputFormat, static function (bool $value) {
228
            return $value ? 'true' : 'false';
229
        });
230
        self::appendIfNotNull($query, 'participantInn', $this->participantInn);
231
        self::appendIfNotNull($query, 'order', $this->order);
232
        self::appendIfNotNull($query, 'did', $this->did);
233
        self::appendIfNotNull($query, 'orderedColumnValue', $this->orderedColumnValue);
234
        self::appendIfNotNull($query, 'orderColumn', $this->orderColumn);
235
        self::appendIfNotNull($query, 'pageDir', $this->pageDir);
236
        self::appendIfNotNull($query, 'limit', $this->limit);
237
238
        return $query;
239
    }
240
241
    private static function appendIfNotNull(array &$query, string $name, $value, callable $formatter = null): void
242
    {
243
        if ($value !== null) {
244
            $query[$name] = $formatter ? $formatter($value) : $value;
245
        }
246
    }
247
}