DefaultBranch::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 34
dl 0
loc 36
ccs 1
cts 1
cp 1
crap 1
rs 10

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Inspirum\Balikobot\Model\Branch;
6
7
use Inspirum\Arrayable\BaseModel;
8
9
/**
10
 * @extends \Inspirum\Arrayable\BaseModel<string,mixed>
11
 */
12
final class DefaultBranch extends BaseModel implements Branch
13
{
14 225
    public function __construct(
15
        private readonly string $carrier,
16
        private readonly ?string $service,
17
        private readonly string $branchId,
18
        private readonly ?string $id,
19
        private readonly ?string $uid,
20
        private readonly string $type,
21
        private readonly string $name,
22
        private readonly string $city,
23
        private readonly string $street,
24
        private readonly string $zip,
25
        private readonly ?string $country = null,
26
        private readonly ?string $cityPart = null,
27
        private readonly ?string $district = null,
28
        private readonly ?string $region = null,
29
        private readonly ?string $currency = null,
30
        private readonly ?string $photoSmall = null,
31
        private readonly ?string $photoBig = null,
32
        private readonly ?string $url = null,
33
        private readonly ?float $latitude = null,
34
        private readonly ?float $longitude = null,
35
        private readonly ?string $directionsGlobal = null,
36
        private readonly ?string $directionsCar = null,
37
        private readonly ?string $directionsPublic = null,
38
        private readonly ?bool $wheelchairAccessible = null,
39
        private readonly ?bool $claimAssistant = null,
40
        private readonly ?bool $dressingRoom = null,
41
        private readonly ?string $openingMonday = null,
42
        private readonly ?string $openingTuesday = null,
43
        private readonly ?string $openingWednesday = null,
44
        private readonly ?string $openingThursday = null,
45
        private readonly ?string $openingFriday = null,
46
        private readonly ?string $openingSaturday = null,
47
        private readonly ?string $openingSunday = null,
48
        private readonly ?float $maxWeight = null,
49
    ) {
50 225
    }
51
52 3
    public function getCarrier(): string
53
    {
54 3
        return $this->carrier;
55
    }
56
57 3
    public function getService(): ?string
58
    {
59 3
        return $this->service;
60
    }
61
62 1
    public function getBranchId(): string
63
    {
64 1
        return $this->branchId;
65
    }
66
67 4
    public function getId(): ?string
68
    {
69 4
        return $this->id;
70
    }
71
72 1
    public function getUid(): ?string
73
    {
74 1
        return $this->uid;
75
    }
76
77 4
    public function getType(): string
78
    {
79 4
        return $this->type;
80
    }
81
82 4
    public function getName(): string
83
    {
84 4
        return $this->name;
85
    }
86
87 3
    public function getCity(): string
88
    {
89 3
        return $this->city;
90
    }
91
92 5
    public function getStreet(): string
93
    {
94 5
        return $this->street;
95
    }
96
97 3
    public function getZip(): string
98
    {
99 3
        return $this->zip;
100
    }
101
102 39
    public function getCountry(): ?string
103
    {
104 39
        return $this->country;
105
    }
106
107 3
    public function getCityPart(): ?string
108
    {
109 3
        return $this->cityPart;
110
    }
111
112 3
    public function getDistrict(): ?string
113
    {
114 3
        return $this->district;
115
    }
116
117 3
    public function getRegion(): ?string
118
    {
119 3
        return $this->region;
120
    }
121
122 3
    public function getCurrency(): ?string
123
    {
124 3
        return $this->currency;
125
    }
126
127 3
    public function getPhotoSmall(): ?string
128
    {
129 3
        return $this->photoSmall;
130
    }
131
132 3
    public function getPhotoBig(): ?string
133
    {
134 3
        return $this->photoBig;
135
    }
136
137 3
    public function getUrl(): ?string
138
    {
139 3
        return $this->url;
140
    }
141
142 3
    public function getLatitude(): ?float
143
    {
144 3
        return $this->latitude;
145
    }
146
147 3
    public function getLongitude(): ?float
148
    {
149 3
        return $this->longitude;
150
    }
151
152 3
    public function getDirectionsGlobal(): ?string
153
    {
154 3
        return $this->directionsGlobal;
155
    }
156
157 3
    public function getDirectionsCar(): ?string
158
    {
159 3
        return $this->directionsCar;
160
    }
161
162 3
    public function getDirectionsPublic(): ?string
163
    {
164 3
        return $this->directionsPublic;
165
    }
166
167 3
    public function getWheelchairAccessible(): ?bool
168
    {
169 3
        return $this->wheelchairAccessible;
170
    }
171
172 3
    public function getClaimAssistant(): ?bool
173
    {
174 3
        return $this->claimAssistant;
175
    }
176
177 3
    public function getDressingRoom(): ?bool
178
    {
179 3
        return $this->dressingRoom;
180
    }
181
182 3
    public function getOpeningMonday(): ?string
183
    {
184 3
        return $this->openingMonday;
185
    }
186
187 3
    public function getOpeningTuesday(): ?string
188
    {
189 3
        return $this->openingTuesday;
190
    }
191
192 3
    public function getOpeningWednesday(): ?string
193
    {
194 3
        return $this->openingWednesday;
195
    }
196
197 3
    public function getOpeningThursday(): ?string
198
    {
199 3
        return $this->openingThursday;
200
    }
201
202 3
    public function getOpeningFriday(): ?string
203
    {
204 3
        return $this->openingFriday;
205
    }
206
207 3
    public function getOpeningSaturday(): ?string
208
    {
209 3
        return $this->openingSaturday;
210
    }
211
212 3
    public function getOpeningSunday(): ?string
213
    {
214 3
        return $this->openingSunday;
215
    }
216
217 3
    public function getMaxWeight(): ?float
218
    {
219 3
        return $this->maxWeight;
220
    }
221
222
    /** @inheritDoc */
223 1
    public function __toArray(): array
224
    {
225 1
        return [
226 1
            'carrier' => $this->carrier,
227 1
            'service' => $this->service,
228 1
            'branchId' => $this->branchId,
229 1
            'id' => $this->id,
230 1
            'uid' => $this->uid,
231 1
            'type' => $this->type,
232 1
            'name' => $this->name,
233 1
            'city' => $this->city,
234 1
            'street' => $this->street,
235 1
            'zip' => $this->zip,
236 1
            'country' => $this->country,
237 1
            'cityPart' => $this->cityPart,
238 1
            'district' => $this->district,
239 1
            'region' => $this->region,
240 1
            'currency' => $this->currency,
241 1
            'photoSmall' => $this->photoSmall,
242 1
            'photoBig' => $this->photoBig,
243 1
            'url' => $this->url,
244 1
            'latitude' => $this->latitude,
245 1
            'longitude' => $this->longitude,
246 1
            'directionsGlobal' => $this->directionsGlobal,
247 1
            'directionsCar' => $this->directionsCar,
248 1
            'directionsPublic' => $this->directionsPublic,
249 1
            'wheelchairAccessible' => $this->wheelchairAccessible,
250 1
            'claimAssistant' => $this->claimAssistant,
251 1
            'dressingRoom' => $this->dressingRoom,
252 1
            'openingMonday' => $this->openingMonday,
253 1
            'openingTuesday' => $this->openingTuesday,
254 1
            'openingWednesday' => $this->openingWednesday,
255 1
            'openingThursday' => $this->openingThursday,
256 1
            'openingFriday' => $this->openingFriday,
257 1
            'openingSaturday' => $this->openingSaturday,
258 1
            'openingSunday' => $this->openingSunday,
259 1
            'maxWeight' => $this->maxWeight,
260 1
        ];
261
    }
262
}
263