1 | <?php |
||
4 | class Fee |
||
5 | { |
||
6 | const DEFAULT_PERCENTAGE = 0.015; |
||
7 | const DEFAULT_ADDITIONAL_CHARGE = 10000; |
||
8 | const DEFAULT_THRESHOLD = 250000; |
||
9 | const DEFAULT_CAP = 200000; |
||
10 | |||
11 | public static $default_percentage = Fee::DEFAULT_PERCENTAGE; |
||
12 | public static $default_additional_charge = Fee::DEFAULT_ADDITIONAL_CHARGE; |
||
13 | public static $default_threshold = Fee::DEFAULT_THRESHOLD; |
||
14 | public static $default_cap = Fee::DEFAULT_CAP; |
||
15 | |||
16 | private $percentage; |
||
17 | private $additional_charge; |
||
18 | private $threshold; |
||
19 | private $cap; |
||
20 | |||
21 | private $chargeDivider; |
||
22 | private $crossover; |
||
23 | private $flatlinePlusCharge; |
||
24 | private $flatline; |
||
25 | |||
26 | 4 | public function __construct() |
|
34 | |||
35 | 2 | public function withPercentage($percentage) |
|
40 | |||
41 | 1 | public static function resetDefaults() |
|
48 | |||
49 | 2 | public function withAdditionalCharge($additional_charge) |
|
54 | |||
55 | 2 | public function withThreshold($threshold) |
|
60 | |||
61 | 2 | public function withCap($cap) |
|
66 | |||
67 | 4 | private function __setup() |
|
74 | |||
75 | 4 | private function __chargeDivider() |
|
76 | { |
||
77 | 4 | return 1 - $this->percentage; |
|
78 | } |
||
79 | |||
80 | 4 | private function __crossover() |
|
84 | |||
85 | 4 | private function __flatlinePlusCharge() |
|
86 | { |
||
87 | 4 | return ($this->cap - $this->additional_charge) / $this->percentage; |
|
88 | } |
||
89 | |||
90 | 4 | private function __flatline() |
|
94 | |||
95 | 3 | public function addFor($amountinkobo) |
|
105 | |||
106 | 2 | public function calculateFor($amountinkobo) |
|
117 | } |
||
118 |