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 | public function __construct($value = 0, $unit = self::KG, array $options = []) |
||
36 | 176 | ||
37 | 176 | /* ------------------------------------------------------------------------------------------------ |
|
38 | 176 | | Getters & Setters |
|
39 | 176 | | ------------------------------------------------------------------------------------------------ |
|
40 | 176 | */ |
|
41 | 176 | /** |
|
42 | 132 | * Get the default names. |
|
43 | 176 | * |
|
44 | * @return array |
||
45 | */ |
||
46 | public function defaultNames() |
||
55 | |||
56 | 8 | /* ------------------------------------------------------------------------------------------------ |
|
57 | 8 | | Main Functions |
|
58 | 6 | | ------------------------------------------------------------------------------------------------ |
|
59 | 6 | */ |
|
60 | 6 | /** |
|
61 | 6 | * Make a weight instance. |
|
62 | * |
||
63 | * @param float|int $value |
||
64 | * @param string $unit |
||
65 | * @param array $options |
||
66 | * |
||
67 | * @return static |
||
68 | */ |
||
69 | public static function make($value = 0, $unit = self::KG, array $options = []) |
||
73 | 8 | ||
74 | /* ------------------------------------------------------------------------------------------------ |
||
75 | 8 | | 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 | public function addWeight($value, $unit = self::KG) |
||
90 | |||
91 | 64 | /** |
|
92 | * Sub the weight. |
||
93 | 64 | * |
|
94 | * @param float|int $value |
||
95 | * @param string $unit |
||
96 | * |
||
97 | * @return self |
||
98 | */ |
||
99 | public function subWeight($value, $unit = self::KG) |
||
103 | 64 | ||
104 | /* ------------------------------------------------------------------------------------------------ |
||
105 | 64 | | Other Functions |
|
106 | | ------------------------------------------------------------------------------------------------ |
||
107 | 16 | */ |
|
108 | /** |
||
109 | 16 | * Get the weight convert ratio. |
|
110 | * |
||
111 | * @param string $to |
||
112 | * @param string $from |
||
113 | * |
||
114 | * @return double|float|integer |
||
115 | */ |
||
116 | protected static function getRatio($to, $from) |
||
127 | |||
128 | /** |
||
129 | * Get all the weight ratios. |
||
130 | * |
||
131 | * @return array |
||
132 | */ |
||
133 | protected static function getRatios() |
||
147 | } |
||
148 |