1 | <?php |
||
2 | |||
3 | |||
4 | namespace Alkoumi\LaravelArabicTafqeet\Helpers; |
||
5 | |||
6 | |||
7 | trait Handler |
||
8 | { |
||
9 | |||
10 | public function setAmount($number = 0) |
||
11 | { |
||
12 | $this->parsed_number = $number . ''; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
13 | return $this; |
||
14 | } |
||
15 | |||
16 | private function split_parsed_number_to_two_number_depend_on_comma() |
||
17 | { |
||
18 | $arr = explode('.',$this->parsed_number); |
||
19 | $this->parsed_number_array = $arr; |
||
0 ignored issues
–
show
|
|||
20 | $this->all_numbers_len = count($this->parsed_number_array); |
||
0 ignored issues
–
show
|
|||
21 | return $this; |
||
22 | } |
||
23 | |||
24 | private function split_numbers_before_comma_to_array() |
||
25 | { |
||
26 | $this->before_comma_array = str_split($this->parsed_number_array[0]); |
||
0 ignored issues
–
show
|
|||
27 | $this->before_comma_len = count($this->before_comma_array); |
||
0 ignored issues
–
show
|
|||
28 | return $this; |
||
29 | } |
||
30 | |||
31 | private function split_numbers_after_comma_to_array() |
||
32 | { |
||
33 | if($this->all_numbers_len>=2) |
||
34 | { |
||
35 | $arr = str_split($this->parsed_number_array[1]); |
||
36 | |||
37 | if(count($arr)>=3) |
||
38 | { |
||
39 | $this->after_comma_array = [$arr[0],$arr[1]]; |
||
0 ignored issues
–
show
|
|||
40 | }else |
||
41 | { |
||
42 | $this->after_comma_array = $arr; |
||
43 | } |
||
44 | |||
45 | $this->after_comma_len = count($this->after_comma_array); |
||
0 ignored issues
–
show
|
|||
46 | foreach ($this->after_comma_array as $digit) |
||
47 | { |
||
48 | $this->after_comma_sum.=$digit; |
||
0 ignored issues
–
show
|
|||
49 | } |
||
50 | //dd($this->after_comma_sum == 00); |
||
51 | return $this; |
||
52 | } |
||
53 | $this->after_comma_array = []; |
||
54 | $this->after_comma_len = 0; |
||
55 | return $this; |
||
56 | } |
||
57 | |||
58 | } |
||
59 |