1 | <?php namespace Arcanedev\Units\Measures; |
||
13 | class Weight extends UnitMeasure implements WeightContract |
||
14 | { |
||
15 | /* ------------------------------------------------------------------------------------------------ |
||
16 | | Traits |
||
17 | | ------------------------------------------------------------------------------------------------ |
||
18 | */ |
||
19 | use Calculatable; |
||
20 | |||
21 | /* ------------------------------------------------------------------------------------------------ |
||
22 | | Constructor |
||
23 | | ------------------------------------------------------------------------------------------------ |
||
24 | */ |
||
25 | /** |
||
26 | * Weight constructor. |
||
27 | * |
||
28 | * @param float|int $value |
||
29 | * @param string $unit |
||
30 | * @param array $options |
||
31 | */ |
||
32 | 240 | public function __construct($value = 0, $unit = self::KG, array $options = []) |
|
36 | |||
37 | /* ------------------------------------------------------------------------------------------------ |
||
38 | | Getters & Setters |
||
39 | | ------------------------------------------------------------------------------------------------ |
||
40 | */ |
||
41 | /** |
||
42 | * Get the default names. |
||
43 | * |
||
44 | * @return array |
||
45 | */ |
||
46 | 168 | public function defaultNames() |
|
55 | |||
56 | /* ------------------------------------------------------------------------------------------------ |
||
57 | | Main Functions |
||
58 | | ------------------------------------------------------------------------------------------------ |
||
59 | */ |
||
60 | /** |
||
61 | * Make a weight instance. |
||
62 | * |
||
63 | * @param float|int $value |
||
64 | * @param string $unit |
||
65 | * @param array $options |
||
66 | * |
||
67 | * @return static |
||
68 | */ |
||
69 | 90 | public static function make($value = 0, $unit = self::KG, array $options = []) |
|
73 | |||
74 | /* ------------------------------------------------------------------------------------------------ |
||
75 | | Calculation Functions |
||
76 | | ------------------------------------------------------------------------------------------------ |
||
77 | */ |
||
78 | /** |
||
79 | * Add the weight. |
||
80 | * |
||
81 | * @param float|int $value |
||
82 | * @param string $unit |
||
83 | * |
||
84 | * @return self |
||
85 | */ |
||
86 | 24 | public function addWeight($value, $unit = self::KG) |
|
90 | |||
91 | /** |
||
92 | * Sub the weight. |
||
93 | * |
||
94 | * @param float|int $value |
||
95 | * @param string $unit |
||
96 | * |
||
97 | * @return self |
||
98 | */ |
||
99 | 24 | public function subWeight($value, $unit = self::KG) |
|
103 | |||
104 | /* ------------------------------------------------------------------------------------------------ |
||
105 | | Other Functions |
||
106 | | ------------------------------------------------------------------------------------------------ |
||
107 | */ |
||
108 | /** |
||
109 | * Get the weight convert ratio. |
||
110 | * |
||
111 | * @param string $to |
||
112 | * @param string $from |
||
113 | * |
||
114 | * @return double|float|integer |
||
115 | */ |
||
116 | 24 | protected static function getRatio($to, $from) |
|
127 | |||
128 | /** |
||
129 | * Get all the weight ratios. |
||
130 | * |
||
131 | * @return array |
||
132 | */ |
||
133 | 24 | protected static function getRatios() |
|
147 | } |
||
148 |