Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
14 | class PickPoint extends \Ecommerce\DeliveryProvider { |
||
15 | static $name = 'PickPoint - курьерская служба'; |
||
|
|||
16 | |||
17 | /** |
||
18 | * @param \Ecommerce\Cart $cart |
||
19 | * @return \Money\Sums |
||
20 | */ |
||
21 | static function curl_get_file_contents($URL, $data) { |
||
41 | |||
42 | static function deliveryTime($cart) { |
||
52 | |||
53 | /* $result = json_decode(self::curl_get_file_contents('https://e-solution.pickpoint.ru/api/CreateShipment', [ |
||
54 | * 'SessionId' => $sessionId, |
||
55 | * 'Sendings' => [[ |
||
56 | * 'IKN' => $config['ikn']->value, |
||
57 | * 'Invoice' => [ |
||
58 | * 'Description' => 'test', |
||
59 | * 'PostamatNumber' => $toId, |
||
60 | * 'MobilePhone' => '+79999999999', |
||
61 | * 'PostageType' => '10003', |
||
62 | * 'GettingType' => '101', |
||
63 | * 'PayType' => 1, |
||
64 | * 'Sum' => '1000' |
||
65 | * ] |
||
66 | * ]], |
||
67 | * ]), true); |
||
68 | * var_dump($result); |
||
69 | * $result = json_decode(self::curl_get_file_contents('https://e-solution.pickpoint.ru/api/calctariff', [ |
||
70 | * 'SessionId' => $sessionId, |
||
71 | * 'FromCity' => $senderCity, |
||
72 | * 'IKN' => $config['ikn']->value, |
||
73 | * 'PTNumber' => $toId, |
||
74 | * 'Length' => 25, |
||
75 | * 'Depth' => 25, |
||
76 | * 'Width' => 25, |
||
77 | * 'Weight' => 0.5, |
||
78 | * ]), true); |
||
79 | * |
||
80 | * $summ = 0; |
||
81 | * var_dump($result['Services']); |
||
82 | * foreach ($result['Services'] as $service) { |
||
83 | * $summ = $service['Tariff'] + $service['NDS']; |
||
84 | * } |
||
85 | * //$result = json_decode(self::curl_get_file_contents('https://e-solution.pickpoint.ru/api/cancelInvoice', ['SessionId' => $sessionId, 'InvoiceNumber' => '15938160323']), true); |
||
86 | */ |
||
87 | static function request($cart) { |
||
141 | |||
142 | /** |
||
143 | * @param \Ecommerce\Cart $cart |
||
144 | * @return \Money\Sums |
||
145 | */ |
||
146 | static function calcPrice($cart) { |
||
166 | |||
167 | static function availablePayTypeGroups($cart) { |
||
170 | } |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.