Issues (22)

src/helpers/Handler.php (8 issues)

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
The property parsed_number does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
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
Bug Best Practice introduced by
The property parsed_number_array does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20
        $this->all_numbers_len = count($this->parsed_number_array);
0 ignored issues
show
Bug Best Practice introduced by
The property all_numbers_len does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
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
Bug Best Practice introduced by
The property before_comma_array does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
27
        $this->before_comma_len = count($this->before_comma_array);
0 ignored issues
show
Bug Best Practice introduced by
The property before_comma_len does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
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
Bug Best Practice introduced by
The property after_comma_array does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
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
Bug Best Practice introduced by
The property after_comma_len does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
46
            foreach ($this->after_comma_array as $digit)
47
            {
48
                $this->after_comma_sum.=$digit;
0 ignored issues
show
The property after_comma_sum does not exist on Alkoumi\LaravelArabicTafqeet\Helpers\Handler. Did you mean after_comma_len?
Loading history...
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