1 | <?php |
||
31 | class Increment |
||
32 | { |
||
33 | |||
34 | /** |
||
35 | * Increment |
||
36 | * |
||
37 | * @var float |
||
38 | * |
||
39 | * @access protected |
||
40 | */ |
||
41 | protected $increment; |
||
42 | |||
43 | /** |
||
44 | * Rounder |
||
45 | * |
||
46 | * @var RoundTo |
||
47 | * |
||
48 | * @access protected |
||
49 | */ |
||
50 | protected $rounder; |
||
51 | |||
52 | /** |
||
53 | * __construct |
||
54 | * |
||
55 | * @param float $increment round to value |
||
56 | * |
||
57 | * @access public |
||
58 | */ |
||
59 | 1 | public function __construct($increment) |
|
64 | |||
65 | /** |
||
66 | * Named constructor for rounding to eighth |
||
67 | * |
||
68 | * @return Increment |
||
69 | * |
||
70 | * @access public |
||
71 | * @static |
||
72 | */ |
||
73 | 1 | public static function eighth() |
|
77 | |||
78 | /** |
||
79 | * Named constructor for rounding to quarter |
||
80 | * |
||
81 | * @return Increment |
||
82 | * |
||
83 | * @access public |
||
84 | * @static |
||
85 | */ |
||
86 | 1 | public static function quarter() |
|
90 | |||
91 | /** |
||
92 | * Named constructor for rounding to half |
||
93 | * |
||
94 | * @return Increment |
||
95 | * |
||
96 | * @access public |
||
97 | * @static |
||
98 | */ |
||
99 | 1 | public static function half() |
|
103 | |||
104 | /** |
||
105 | * Round value to nearest increment |
||
106 | * |
||
107 | * @param float $value value to round |
||
108 | * |
||
109 | * @return float |
||
110 | * |
||
111 | * @access public |
||
112 | */ |
||
113 | 1 | public function nearest($value) |
|
117 | |||
118 | /** |
||
119 | * Round value to next increment |
||
120 | * |
||
121 | * @param float $value value to round |
||
122 | * |
||
123 | * @return float |
||
124 | * |
||
125 | * @access public |
||
126 | */ |
||
127 | 1 | public function next($value) |
|
131 | |||
132 | /** |
||
133 | * Round value to previous increment |
||
134 | * |
||
135 | * @param float $value value to round |
||
136 | * |
||
137 | * @return float |
||
138 | * |
||
139 | * @access public |
||
140 | */ |
||
141 | 1 | public function previous($value) |
|
145 | |||
146 | /** |
||
147 | * Proxy to self::nearest |
||
148 | * |
||
149 | * @param float $value value to round |
||
150 | * |
||
151 | * @return float |
||
152 | * |
||
153 | * @access public |
||
154 | */ |
||
155 | 1 | public function __invoke($value) |
|
159 | } |
||
160 | |||
161 |