PluginProbe
PostNL for WooCommerce / 4.4.0
PostNL for WooCommerce v4.4.0
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / vendor / myparcelnl / sdk / src / Factory / ConsignmentFactory.php

ConsignmentFactory.php in PostNL for WooCommerce 4.4.0, at vendor/myparcelnl/sdk/src/Factory/ConsignmentFactory.php

51 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare(strict_types=1);
3 /**
4 * If you want to add improvements, please create a fork in our GitHub:
5 * https://github.com/myparcelnl
6 *
7 * @author Richard Perdaan <[email protected]>
8 * @copyright 2010-2019 MyParcel
9 * @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US CC BY-NC-ND 3.0 NL
10 * @link https://github.com/myparcelnl/sdk
11 * @since File available since Release v3.0.0
12 */
13
14 namespace MyParcelNL\Sdk\src\Factory;
15
16 use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment;
17 use MyParcelNL\Sdk\src\Model\Consignment\PostNLConsignment;
18 use MyParcelNL\Sdk\src\Model\Consignment\BpostConsignment;
19 use MyParcelNL\Sdk\src\Model\Consignment\DPDConsignment;
20
21 class ConsignmentFactory
22 {
23 public static function createByCarrierId(int $carrierId): AbstractConsignment
24 {
25 switch ($carrierId) {
26 case PostNLConsignment::CARRIER_ID:
27 return new PostNLConsignment();
28 case BpostConsignment::CARRIER_ID:
29 return new BpostConsignment();
30 case DPDConsignment::CARRIER_ID:
31 return new DPDConsignment();
32 }
33
34 throw new \BadMethodCallException("Carrier id $carrierId not found");
35 }
36
37 public static function createByCarrierName(string $carrierName): AbstractConsignment
38 {
39 switch ($carrierName) {
40 case PostNLConsignment::CARRIER_NAME:
41 return new PostNLConsignment();
42 case BpostConsignment::CARRIER_NAME:
43 return new BpostConsignment();
44 case DPDConsignment::CARRIER_NAME:
45 return new DPDConsignment();
46 }
47
48 throw new \BadMethodCallException("Carrier name $carrierName not found");
49 }
50 }
51