@@ -7,15 +7,15 @@ |
||
7 | 7 | * Code inspired from the SplClassLoader RFC |
8 | 8 | * @see https://wiki.php.net/rfc/splclassloader#example_implementation |
9 | 9 | */ |
10 | -spl_autoload_register(function ($className) { |
|
10 | +spl_autoload_register(function($className) { |
|
11 | 11 | $className = ltrim($className, '\\'); |
12 | 12 | $fileName = ''; |
13 | 13 | if ($lastNsPos = strripos($className, '\\')) { |
14 | 14 | $namespace = substr($className, 0, $lastNsPos); |
15 | - $className = substr($className, $lastNsPos + 1); |
|
16 | - $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; |
|
15 | + $className = substr($className, $lastNsPos+1); |
|
16 | + $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR; |
|
17 | 17 | } |
18 | - $fileName = __DIR__ . DIRECTORY_SEPARATOR . $fileName . $className . '.php'; |
|
18 | + $fileName = __DIR__.DIRECTORY_SEPARATOR.$fileName.$className.'.php'; |
|
19 | 19 | if (file_exists($fileName)) { |
20 | 20 | require $fileName; |
21 | 21 |
@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | public static function toDatabase(string $phone) |
12 | 12 | { |
13 | 13 | $phone = preg_replace('/[^0-9]/', '', $phone); |
14 | - if (substr((string) $phone,0,2)=='55') { |
|
14 | + if (substr((string) $phone, 0, 2) == '55') { |
|
15 | 15 | return $phone; |
16 | 16 | } |
17 | - if (empty($phone) || $phone=='55') { |
|
17 | + if (empty($phone) || $phone == '55') { |
|
18 | 18 | return null; |
19 | 19 | } |
20 | 20 | if (strlen($phone)>11) { |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | { |
33 | 33 | $phone = self::break($phoneNumber); |
34 | 34 | |
35 | - if ((int) $phone['country'] === 0 ) { |
|
35 | + if ((int) $phone['country'] === 0) { |
|
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | |
39 | - if ((int) $phone['region'] === 0 ) { |
|
39 | + if ((int) $phone['region'] === 0) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | - if ((int) $phone['number'] === 0 ) { |
|
43 | + if ((int) $phone['number'] === 0) { |
|
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
47 | - if (strlen(static::toDatabase($phoneNumber)) < 12 || strlen(static::toDatabase($phoneNumber)) > 13) { |
|
47 | + if (strlen(static::toDatabase($phoneNumber))<12 || strlen(static::toDatabase($phoneNumber))>13) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | public static function isSame(string $to, string $from) |
75 | 75 | { |
76 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
76 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public static function toDatabase(string $number) |
15 | 15 | { |
16 | - if(strpos($number, ',') > 0) { |
|
16 | + if (strpos($number, ',')>0) { |
|
17 | 17 | $number = str_replace('.', '', $number); |
18 | 18 | $number = str_replace(',', '.', $number); |
19 | 19 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public static function isSame(string $to, string $from) |
34 | 34 | { |
35 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
35 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | public static function toDatabase($dataOriginal) |
14 | 14 | { |
15 | 15 | $data = explode('/', $dataOriginal); |
16 | - if (isset($data[2])){ |
|
17 | - if($data[1]>12){ |
|
18 | - return $data[2] .'-'. $data[0] .'-'. $data[1]; |
|
16 | + if (isset($data[2])) { |
|
17 | + if ($data[1]>12) { |
|
18 | + return $data[2].'-'.$data[0].'-'.$data[1]; |
|
19 | 19 | } |
20 | - return $data[2] .'-'. $data[1] .'-'. $data[0]; |
|
20 | + return $data[2].'-'.$data[1].'-'.$data[0]; |
|
21 | 21 | } |
22 | 22 | return $dataOriginal; |
23 | 23 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | if ($year>99) { |
64 | 64 | return $year; |
65 | 65 | } |
66 | - if ($year>50){ |
|
66 | + if ($year>50) { |
|
67 | 67 | return 1900+$year; |
68 | 68 | } |
69 | 69 | return 2000+$year; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | public static function isSame(string $to, string $from) |
73 | 73 | { |
74 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
74 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public static function toDatabase($gender) |
25 | 25 | { |
26 | - return substr(((string) self::filter(strtoupper(preg_replace('/[^A-z]/', '',$gender)))), 0, 1); |
|
26 | + return substr(((string) self::filter(strtoupper(preg_replace('/[^A-z]/', '', $gender)))), 0, 1); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function filter($gender) { |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | |
39 | 39 | public static function toUser($gender) |
40 | 40 | { |
41 | - if($gender == 'M') { |
|
41 | + if ($gender == 'M') { |
|
42 | 42 | return 'Masculino'; |
43 | 43 | } |
44 | 44 | |
45 | - if($gender == 'F') { |
|
45 | + if ($gender == 'F') { |
|
46 | 46 | return 'Feminino'; |
47 | 47 | } |
48 | 48 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | public static function isSame(string $to, string $from) |
64 | 64 | { |
65 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
65 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | } |
@@ -13,13 +13,13 @@ |
||
13 | 13 | if ($maskLen !== $numberLen) { |
14 | 14 | return false; |
15 | 15 | } |
16 | - while($i < $maskLen) { |
|
17 | - if (strtoupper($mask[$i])!=='X' && strtoupper($mask[$i])!=='#'){ |
|
18 | - if ($mask[$i]!==$number[$i]) { |
|
16 | + while ($i<$maskLen) { |
|
17 | + if (strtoupper($mask[$i]) !== 'X' && strtoupper($mask[$i]) !== '#') { |
|
18 | + if ($mask[$i] !== $number[$i]) { |
|
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | } |
22 | - $i = $i + 1; |
|
22 | + $i = $i+1; |
|
23 | 23 | } |
24 | 24 | return true; |
25 | 25 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public static function validate($cep) |
24 | 24 | { |
25 | - if (preg_match('/[0-9]{2,2}([.]?)[0-9]{3,3}([- ]?)[0-9]{3}$/', $cep) == 0 ) { |
|
25 | + if (preg_match('/[0-9]{2,2}([.]?)[0-9]{3,3}([- ]?)[0-9]{3}$/', $cep) == 0) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | try { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | public static function isSame(string $to, string $from) |
46 | 46 | { |
47 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
47 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | |
17 | 17 | public static function validate($birthdate) |
18 | 18 | { |
19 | - if (!parent::validate($birthdate)){ |
|
19 | + if (!parent::validate($birthdate)) { |
|
20 | 20 | return false; |
21 | 21 | } |
22 | 22 | |
23 | 23 | $birthdate = Carbon::createFromFormat('Y-m-d', self::toDatabase($birthdate)); |
24 | - if ($birthdate->greaterThan(Carbon::now())){ |
|
24 | + if ($birthdate->greaterThan(Carbon::now())) { |
|
25 | 25 | return false; |
26 | 26 | } |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public static function isSame(string $to, string $from) |
32 | 32 | { |
33 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
33 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | } |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | public static function validate($creditCardNumber) |
23 | 23 | { |
24 | 24 | $found = false; |
25 | - foreach (self::$cardParams as $masks){ |
|
26 | - foreach ($masks as $mask){ |
|
27 | - if (self::maskIsValidate($creditCardNumber, $mask)){ |
|
25 | + foreach (self::$cardParams as $masks) { |
|
26 | + foreach ($masks as $mask) { |
|
27 | + if (self::maskIsValidate($creditCardNumber, $mask)) { |
|
28 | 28 | $found = true; |
29 | 29 | } |
30 | 30 | } |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | |
35 | 35 | public static function expirationIsValid($mes, $ano) |
36 | 36 | { |
37 | - if ((int) Date::yearToDatabase($ano) < (int) Carbon::now()->year) { |
|
37 | + if ((int) Date::yearToDatabase($ano)<(int) Carbon::now()->year) { |
|
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | if ((int) Date::yearToDatabase($ano) == (int) Carbon::now()->year) { |
41 | - if ((int) Date::monthToDatabase($mes) < (int) Carbon::now()->month) { |
|
41 | + if ((int) Date::monthToDatabase($mes)<(int) Carbon::now()->month) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | public static function isSame(string $to, string $from) |
59 | 59 | { |
60 | - return (self::toDatabase($to)===self::toDatabase($from)); |
|
60 | + return (self::toDatabase($to) === self::toDatabase($from)); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | } |