1 | <?php |
||
11 | class RoundingRule implements ArrayInterface |
||
12 | { |
||
13 | const NONE = 'none'; |
||
14 | const POUND = 'pound'; |
||
15 | const POUND_UP = 'pound-up'; |
||
16 | const POUND_DOWN = 'pound-down'; |
||
17 | const FIFTY = 'fifty'; |
||
18 | const FIFTY_UP = 'fifty_up'; |
||
19 | const FIFTY_DOWN = 'fifty_down'; |
||
20 | |||
21 | /** |
||
22 | * @var $rounder Rounder |
||
23 | */ |
||
24 | protected $rounder; |
||
25 | |||
26 | 2 | public function __construct(Rounder $rounder) |
|
30 | |||
31 | /** |
||
32 | * Get list of rounding rule options |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | 2 | public function toOptionArray() |
|
37 | { |
||
38 | 2 | $options = []; |
|
39 | |||
40 | 2 | $rules = $this->rounder->getRoundingRules(); |
|
41 | 2 | foreach ($rules as $rule => $name) { |
|
42 | 2 | $options[] = [ |
|
43 | 2 | 'value' => $rule, |
|
44 | 2 | 'label' => __($name) |
|
45 | 2 | ]; |
|
46 | 2 | } |
|
47 | |||
48 | 2 | return $options; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Get options in "key-value" format |
||
53 | * |
||
54 | * @return array |
||
55 | */ |
||
56 | public function toArray() |
||
62 | } |
||
63 |