1 | <?php |
||
8 | abstract class BaseNumbersMiddleware extends TransformsRequest |
||
9 | { |
||
10 | /** @var array */ |
||
11 | protected $except = []; |
||
12 | |||
13 | /** @var string */ |
||
14 | protected $from = 'eastern'; |
||
15 | |||
16 | /** @var array */ |
||
17 | protected $easternNumbers = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩']; |
||
18 | |||
19 | /** @var array|mixed */ |
||
20 | protected $config; |
||
21 | |||
22 | /** |
||
23 | * BaseNumbersMiddleware constructor. |
||
24 | * |
||
25 | * @param Repository $config |
||
26 | */ |
||
27 | 10 | public function __construct(Repository $config) |
|
31 | |||
32 | /** |
||
33 | * get except fields. |
||
34 | * |
||
35 | * @return array |
||
36 | */ |
||
37 | 10 | public function getExcept() |
|
41 | |||
42 | /** |
||
43 | * get options from config. |
||
44 | * @param string $key |
||
45 | * @param null $default |
||
46 | * @return array |
||
47 | */ |
||
48 | 10 | protected function getOption($key, $default = null) |
|
52 | |||
53 | /** |
||
54 | * Transform the given value. |
||
55 | * |
||
56 | * @param string $key |
||
57 | * @param mixed $value |
||
58 | * @return mixed |
||
59 | */ |
||
60 | 10 | protected function transform($key, $value) |
|
68 | |||
69 | /** |
||
70 | * transform eastern/(arabic|english) numbers to (arabic|english)/eastern numbers inside string. |
||
71 | * |
||
72 | * @param string $value |
||
73 | * @return string |
||
74 | */ |
||
75 | 10 | protected function transformNumber($value) |
|
79 | |||
80 | /** |
||
81 | * get array numbers to transforms. |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | 10 | protected function getNumbers() |
|
89 | |||
90 | /** |
||
91 | * check if transform from (arabic|english) to eastern. |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | 10 | public function isFromEastern() |
|
99 | |||
100 | /** |
||
101 | * Get eastern numbers array. |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | 10 | public function getEasternNumbers() |
|
109 | } |
||
110 |