|
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
|
228 |
|
public function hasFullBranchesSupport(string $carrier, ?string $service): bool |
|
14
|
|
|
{ |
|
15
|
228 |
|
$supported = [ |
|
16
|
228 |
|
Carrier::ZASILKOVNA => null, |
|
17
|
228 |
|
Carrier::CP => [ |
|
18
|
228 |
|
Service::CP_NP, |
|
19
|
228 |
|
Service::CP_NB, |
|
20
|
228 |
|
], |
|
21
|
228 |
|
Carrier::PBH => [ |
|
22
|
228 |
|
Service::PBH_SPS, |
|
23
|
228 |
|
Service::PBH_SP, |
|
24
|
228 |
|
Service::PBH_MP, |
|
25
|
228 |
|
Service::PBH_RP, |
|
26
|
228 |
|
Service::PBH_CP_NP, |
|
27
|
228 |
|
Service::PBH_INPOST_KURIER, |
|
28
|
228 |
|
Service::PBH_FAN_KURIER, |
|
29
|
228 |
|
Service::PBH_SPEEDY, |
|
30
|
228 |
|
Service::PBH_ECONT, |
|
31
|
228 |
|
], |
|
32
|
228 |
|
Carrier::DPD => [ |
|
33
|
228 |
|
Service::DPD_PICKUP, |
|
34
|
228 |
|
], |
|
35
|
228 |
|
Carrier::GLS => [ |
|
36
|
228 |
|
Service::GLS_SHOP, |
|
37
|
228 |
|
Service::GLS_GUARANTEED24_SHOP, |
|
38
|
228 |
|
], |
|
39
|
228 |
|
Carrier::INTIME => [ |
|
40
|
228 |
|
Service::INTIME_POSTOMAT_CZ, |
|
41
|
228 |
|
Service::INTIME_BOX_CZ, |
|
42
|
228 |
|
Service::INTIME_BOX_SK, |
|
43
|
228 |
|
], |
|
44
|
228 |
|
Carrier::SPS => [ |
|
45
|
228 |
|
Service::SPS_EXPRESS, |
|
46
|
228 |
|
Service::SPS_INTERNATIONAL, |
|
47
|
228 |
|
], |
|
48
|
228 |
|
Carrier::SP => [ |
|
49
|
228 |
|
Service::SP_BZP, |
|
50
|
228 |
|
Service::SP_BZB, |
|
51
|
228 |
|
Service::SP_EXP, |
|
52
|
228 |
|
Service::SP_EXB, |
|
53
|
228 |
|
Service::SP_BNP, |
|
54
|
228 |
|
Service::SP_BNB, |
|
55
|
228 |
|
], |
|
56
|
228 |
|
Carrier::ULOZENKA => [ |
|
57
|
228 |
|
Service::ULOZENKA_ULOZENKA, |
|
58
|
228 |
|
Service::ULOZENKA_DPD_PARCEL, |
|
59
|
228 |
|
Service::ULOZENKA_CP_NP, |
|
60
|
228 |
|
Service::ULOZENKA_PARTNER, |
|
61
|
228 |
|
Service::ULOZENKA_EXPRESS_SK, |
|
62
|
228 |
|
Service::ULOZENKA_BALIKOBOX_SK, |
|
63
|
228 |
|
Service::ULOZENKA_DEPO_SK, |
|
64
|
228 |
|
], |
|
65
|
228 |
|
Carrier::PPL => [ |
|
66
|
228 |
|
Service::PPL_CONNECT, |
|
67
|
228 |
|
Service::PPL_PRIVATE, |
|
68
|
228 |
|
Service::PPL_PRIVATE_SMART_CZ, |
|
69
|
228 |
|
Service::PPL_PRIVATE_SMART_EU, |
|
70
|
228 |
|
], |
|
71
|
228 |
|
Carrier::SAMEDAY => [ |
|
72
|
228 |
|
Service::SAMEDAY_LOCKER_NEXT_DAY, |
|
73
|
228 |
|
Service::SAMEDAY_LOCKER_RETURN, |
|
74
|
228 |
|
], |
|
75
|
228 |
|
Carrier::MAGYARPOSTA => null, |
|
76
|
228 |
|
]; |
|
77
|
|
|
|
|
78
|
228 |
|
return $this->hasSupport($supported, $carrier, $service); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
212 |
|
public function hasBranchCountryFilterSupport(string $carrier, ?string $service): bool |
|
82
|
|
|
{ |
|
83
|
212 |
|
if ($service === null) { |
|
84
|
1 |
|
return true; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
211 |
|
$supported = [ |
|
88
|
211 |
|
Carrier::PPL => null, |
|
89
|
211 |
|
Carrier::DPD => null, |
|
90
|
211 |
|
Carrier::GLS => null, |
|
91
|
211 |
|
Carrier::ULOZENKA => null, |
|
92
|
211 |
|
Carrier::PBH => [ |
|
93
|
211 |
|
Service::PBH_CP_NP, |
|
94
|
211 |
|
], |
|
95
|
211 |
|
Carrier::SPS => null, |
|
96
|
211 |
|
Carrier::RABEN => null, |
|
97
|
211 |
|
Carrier::SAMEDAY => null, |
|
98
|
211 |
|
Carrier::ZASILKOVNA => null, |
|
99
|
211 |
|
]; |
|
100
|
|
|
|
|
101
|
211 |
|
return $this->hasSupport($supported, $carrier, $service); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @param array<string,array<string>|null> $supported |
|
106
|
|
|
*/ |
|
107
|
438 |
|
private function hasSupport(array $supported, string $carrier, ?string $service): bool |
|
108
|
|
|
{ |
|
109
|
438 |
|
foreach ($supported as $supportedCarrier => $supportedServices) { |
|
110
|
438 |
|
if ($carrier === $supportedCarrier && ($supportedServices === null || in_array($service, $supportedServices, true))) { |
|
111
|
139 |
|
return true; |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
301 |
|
return false; |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|