1 | <?php |
||
20 | class Carrier extends AbstractCarrier implements CarrierInterface |
||
21 | { |
||
22 | /** |
||
23 | * Carrier's code |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $_code = 'rm'; |
||
28 | |||
29 | /** |
||
30 | * Whether this carrier has fixed rates calculation |
||
31 | * |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $_isFixed = true; |
||
35 | |||
36 | /** |
||
37 | * @var ResultFactory |
||
38 | */ |
||
39 | protected $rateResultFactory; |
||
40 | |||
41 | /** |
||
42 | * @var MethodFactory |
||
43 | */ |
||
44 | protected $rateMethodFactory; |
||
45 | |||
46 | /** |
||
47 | * @var LibCarrier |
||
48 | */ |
||
49 | protected $carrier; |
||
50 | |||
51 | /** |
||
52 | * @var Rounder |
||
53 | */ |
||
54 | protected $rounder; |
||
55 | |||
56 | /** |
||
57 | * @param ScopeConfigInterface $scopeConfig |
||
58 | * @param ErrorFactory $rateErrorFactory |
||
59 | * @param LoggerInterface $logger |
||
60 | * @param ResultFactory $rateResultFactory |
||
61 | * @param MethodFactory $rateMethodFactory |
||
62 | * @param Rounder $rounder |
||
63 | * @param array $data |
||
64 | */ |
||
65 | public function __construct( |
||
79 | 8 | ||
80 | 8 | /** |
|
81 | 8 | * Collect and get rates for storefront |
|
82 | * |
||
83 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
84 | * @param RateRequest $request |
||
85 | * @return DataObject|bool|null |
||
86 | * @api |
||
87 | */ |
||
88 | public function collectRates(RateRequest $request) |
||
155 | 6 | ||
156 | |||
157 | 6 | /** |
|
158 | 6 | * Gets the methods selected in the admin area of the extension |
|
159 | * to ensure that not allowed methods can be removed in the collect |
||
160 | 6 | * rates method |
|
161 | * |
||
162 | * @return array |
||
163 | */ |
||
164 | public function getAllowedMethods() |
||
171 | /** |
||
172 | 7 | * Gets the clean method names from the royal mail library data |
|
173 | * class. These names link directly to method names, but are used |
||
174 | * to ensure that duplicates are not created as similar names |
||
175 | * exists for multiple methods. |
||
176 | * |
||
177 | * @return array |
||
178 | 7 | */ |
|
179 | public function getMethods() |
||
196 | |||
197 | /** |
||
198 | * @return LibCarrier |
||
199 | */ |
||
200 | public function getCarrier() |
||
218 | 1 | ||
219 | 1 | /** |
|
220 | * @deprecated |
||
221 | 5 | * @param $libCarrier |
|
222 | * @return $this |
||
223 | */ |
||
224 | public function setCarrier($libCarrier) |
||
229 | |||
230 | /** |
||
231 | * Get package weight in Kilograms converting from lbs if necessary. |
||
232 | 5 | * |
|
233 | * @param $weight |
||
234 | 5 | * @param $unit |
|
235 | 5 | * @return mixed |
|
236 | 1 | */ |
|
237 | 1 | protected function getPackageWeightInKg($weight, $unit) |
|
245 | |||
246 | /** |
||
247 | * Both small and medium sized parcels can serve up to 2KG. |
||
248 | * Configuration option determines which size we show to customer. |
||
249 | * |
||
250 | * @param \Meanbee\RoyalMail\Method[] $methods |
||
251 | * @param int $weight |
||
252 | * @return \Meanbee\RoyalMail\Method[] |
||
253 | */ |
||
254 | protected function removeUnusedParcelSizes($methods, $weight) |
||
267 | } |
||
268 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: