1 | <?php |
||
10 | class ShippingPackage |
||
11 | { |
||
12 | protected $weight; |
||
13 | protected $height; |
||
14 | protected $width; |
||
15 | protected $depth; |
||
16 | protected $diameter; |
||
17 | protected $value; |
||
18 | protected $currency; |
||
19 | protected $quantity; |
||
20 | |||
21 | protected $defaultdimensions = array( |
||
22 | 'height' => 0, |
||
23 | 'width' => 0, |
||
24 | 'depth' => 0, |
||
25 | 'diameter' => 0 |
||
26 | ); |
||
27 | |||
28 | protected $defaultoptions = array( |
||
29 | 'value' => 0, |
||
30 | 'quantity' => 0, |
||
31 | 'shape' => 'box', |
||
32 | 'weightunit' => 'kg', |
||
33 | 'widthunit' => 'cm', |
||
34 | ); |
||
35 | |||
36 | protected $dimensionaliases = array( |
||
37 | 0 => 'height', |
||
38 | 1 => 'width', |
||
39 | 2 => 'depth', |
||
40 | 'h' => 'height', |
||
41 | 'w' => 'width', |
||
42 | 'd' => 'depth' |
||
43 | ); |
||
44 | |||
45 | public function __construct($weight = 0, $dimensions = array(), $options = array()) |
||
77 | |||
78 | public function toArray() |
||
93 | |||
94 | public function __toString() |
||
102 | |||
103 | /** |
||
104 | * Calculate total volume, based on given dimensions |
||
105 | */ |
||
106 | public function volume() |
||
110 | |||
111 | public function weight() |
||
115 | |||
116 | public function height() |
||
120 | |||
121 | public function width() |
||
125 | |||
126 | public function depth() |
||
130 | |||
131 | public function value() |
||
135 | |||
136 | public function quantity() |
||
140 | } |
||
141 |