Number   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 28
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toUser() 0 3 1
A isSame() 0 3 1
A toDatabase() 0 7 2
A validate() 0 3 1
1
<?php
2
3
namespace Validate;
4
5
class Number implements \Validate\Contracts\Validate
6
{
7
    
8
    /**
9
     * Remove Virgulas do Numeral e Add .
10
     */
11
    public static function toDatabase(string $number)
12
    {
13
        if(strpos($number, ',') > 0) {
14
            $number = str_replace('.', '', $number);
15
            $number = str_replace(',', '.', $number);
16
        }
17
        return $number;
18
    }
19
20
    public static function toUser($number)
21
    {
22
        return $number;
23
    }
24
25
    public static function validate($number)
26
    {
27
        return true;
28
    }
29
30
    public static function isSame(string $to, string $from)
31
    {
32
        return (self::toDatabase($to)===self::toDatabase($from));
33
    }
34
35
}
36