1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Inspirum\Balikobot\Model\Branch; |
6
|
|
|
|
7
|
|
|
use Inspirum\Balikobot\Definitions\Carrier; |
8
|
|
|
use Inspirum\Balikobot\Definitions\Service; |
9
|
|
|
use function in_array; |
10
|
|
|
|
11
|
|
|
final class DefaultBranchResolver implements BranchResolver |
12
|
|
|
{ |
13
|
246 |
|
public function hasFullBranchesSupport(string $carrier, ?string $service): bool |
14
|
|
|
{ |
15
|
246 |
|
$supported = [ |
16
|
246 |
|
Carrier::ZASILKOVNA => null, |
17
|
246 |
|
Carrier::CP => [ |
18
|
246 |
|
Service::CP_NP, |
19
|
246 |
|
Service::CP_NB, |
20
|
246 |
|
], |
21
|
246 |
|
Carrier::PBH => [ |
22
|
246 |
|
Service::PBH_DHL, |
23
|
246 |
|
Service::PBH_SPS, |
24
|
246 |
|
Service::PBH_SP, |
25
|
246 |
|
Service::PBH_MP, |
26
|
246 |
|
Service::PBH_RP, |
27
|
246 |
|
Service::PBH_CP_NP, |
28
|
246 |
|
Service::PBH_INPOST_KURIER, |
29
|
246 |
|
Service::PBH_FAN_KURIER, |
30
|
246 |
|
Service::PBH_SPEEDY, |
31
|
246 |
|
Service::PBH_ECONT, |
32
|
246 |
|
Service::PBH_HR_POST, |
33
|
246 |
|
Service::PBH_BOX_NOW, |
34
|
246 |
|
Service::PBH_SI, |
35
|
246 |
|
Service::PBH_ITELLA, |
36
|
246 |
|
Service::PBH_CP_NB, |
37
|
246 |
|
], |
38
|
246 |
|
Carrier::DPD => [ |
39
|
246 |
|
Service::DPD_PICKUP, |
40
|
246 |
|
], |
41
|
246 |
|
Carrier::GLS => [ |
42
|
246 |
|
Service::GLS_SHOP, |
43
|
246 |
|
Service::GLS_GUARANTEED24_SHOP, |
44
|
246 |
|
], |
45
|
246 |
|
Carrier::INTIME => [ |
46
|
246 |
|
Service::INTIME_POSTOMAT_CZ, |
47
|
246 |
|
Service::INTIME_BOX_CZ, |
48
|
246 |
|
Service::INTIME_BOX_SK, |
49
|
246 |
|
], |
50
|
246 |
|
Carrier::SPS => [ |
51
|
246 |
|
Service::SPS_EXPRESS, |
52
|
246 |
|
Service::SPS_INTERNATIONAL, |
53
|
246 |
|
], |
54
|
246 |
|
Carrier::SP => [ |
55
|
246 |
|
Service::SP_BZP, |
56
|
246 |
|
Service::SP_BZB, |
57
|
246 |
|
Service::SP_EXP, |
58
|
246 |
|
Service::SP_EXB, |
59
|
246 |
|
Service::SP_BNP, |
60
|
246 |
|
Service::SP_BNB, |
61
|
246 |
|
], |
62
|
246 |
|
Carrier::ULOZENKA => [ |
|
|
|
|
63
|
246 |
|
Service::ULOZENKA_ULOZENKA, |
64
|
246 |
|
Service::ULOZENKA_DPD_PARCEL, |
|
|
|
|
65
|
246 |
|
Service::ULOZENKA_CP_NP, |
|
|
|
|
66
|
246 |
|
Service::ULOZENKA_PARTNER, |
|
|
|
|
67
|
246 |
|
Service::ULOZENKA_EXPRESS_SK, |
|
|
|
|
68
|
246 |
|
Service::ULOZENKA_BALIKOBOX_SK, |
|
|
|
|
69
|
246 |
|
Service::ULOZENKA_DEPO_SK, |
|
|
|
|
70
|
246 |
|
], |
71
|
246 |
|
Carrier::PPL => [ |
72
|
246 |
|
Service::PPL_CONNECT, |
73
|
246 |
|
Service::PPL_PRIVATE, |
74
|
246 |
|
Service::PPL_PRIVATE_SMART_CZ, |
75
|
246 |
|
Service::PPL_PRIVATE_SMART_EU, |
76
|
246 |
|
], |
77
|
246 |
|
Carrier::SAMEDAY => [ |
78
|
246 |
|
Service::SAMEDAY_LOCKER_NEXT_DAY, |
79
|
246 |
|
Service::SAMEDAY_LOCKER_RETURN, |
80
|
246 |
|
Service::SAMEDAY_CROSSBORDER_LOCKER_HD, |
81
|
246 |
|
], |
82
|
246 |
|
Carrier::MAGYARPOSTA => null, |
83
|
246 |
|
Carrier::RABEN => [ |
84
|
246 |
|
Service::RABEN_CLASSIC_TIME, |
85
|
246 |
|
Service::RABEN_PREMIUM_TIME, |
86
|
246 |
|
], |
87
|
246 |
|
Carrier::DHLFREIGHTEC => [ |
88
|
246 |
|
Service::DHLFREIGHTEC_ECD_B2B, |
89
|
246 |
|
Service::DHLFREIGHTEC_ECD_B2C, |
90
|
246 |
|
], |
91
|
246 |
|
Carrier::KURIER => [ |
|
|
|
|
92
|
246 |
|
Service::KURIER_GARANTED, |
|
|
|
|
93
|
246 |
|
Service::KURIER_GARANTED_BRANCH, |
|
|
|
|
94
|
246 |
|
Service::KURIER_STANDARD, |
|
|
|
|
95
|
246 |
|
Service::KURIER_STANDARD_BRANCH, |
|
|
|
|
96
|
246 |
|
], |
97
|
246 |
|
Carrier::INPOST => null, |
98
|
246 |
|
]; |
99
|
|
|
|
100
|
246 |
|
return $this->hasSupport($supported, $carrier, $service); |
101
|
|
|
} |
102
|
|
|
|
103
|
242 |
|
public function hasBranchCountryFilterSupport(string $carrier, ?string $service): bool |
104
|
|
|
{ |
105
|
242 |
|
if ($service === null) { |
106
|
1 |
|
return true; |
107
|
|
|
} |
108
|
|
|
|
109
|
241 |
|
$supported = [ |
110
|
241 |
|
Carrier::PPL => null, |
111
|
241 |
|
Carrier::DPD => null, |
112
|
241 |
|
Carrier::GLS => null, |
113
|
241 |
|
Carrier::PBH => [ |
114
|
241 |
|
Service::PBH_DHL, |
115
|
241 |
|
Service::PBH_CP_NP, |
116
|
241 |
|
Service::PBH_SPS, |
117
|
241 |
|
Service::PBH_SP, |
118
|
241 |
|
Service::PBH_MP, |
119
|
241 |
|
Service::PBH_RP, |
120
|
241 |
|
Service::PBH_INPOST_KURIER, |
121
|
241 |
|
Service::PBH_FAN_KURIER, |
122
|
241 |
|
Service::PBH_SPEEDY, |
123
|
241 |
|
Service::PBH_ECONT, |
124
|
241 |
|
Service::PBH_HR_POST, |
125
|
241 |
|
Service::PBH_BOX_NOW, |
126
|
241 |
|
Service::PBH_SI, |
127
|
241 |
|
Service::PBH_ITELLA, |
128
|
241 |
|
Service::PBH_CP_NB, |
129
|
241 |
|
], |
130
|
241 |
|
Carrier::SPS => null, |
131
|
241 |
|
Carrier::RABEN => null, |
132
|
241 |
|
Carrier::SAMEDAY => null, |
133
|
241 |
|
Carrier::ZASILKOVNA => null, |
134
|
241 |
|
Carrier::MAGYARPOSTA => null, |
135
|
241 |
|
Carrier::ONEBYALLEGRO => [ |
136
|
241 |
|
Service::ONEBYALLEGRO_BOX_STANDARD, |
137
|
241 |
|
Service::ONEBYALLEGRO_POINT_STANDARD, |
138
|
241 |
|
], |
139
|
241 |
|
]; |
140
|
|
|
|
141
|
241 |
|
return $this->hasSupport($supported, $carrier, $service); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param array<string,list<string>|null> $supported |
|
|
|
|
146
|
|
|
*/ |
147
|
487 |
|
private function hasSupport(array $supported, string $carrier, ?string $service): bool |
148
|
|
|
{ |
149
|
487 |
|
foreach ($supported as $supportedCarrier => $supportedServices) { |
150
|
487 |
|
if ($carrier === $supportedCarrier && ($supportedServices === null || in_array($service, $supportedServices, true))) { |
151
|
204 |
|
return true; |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
155
|
284 |
|
return false; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.