@@ -16,62 +16,62 @@ discard block  | 
                                                    ||
| 16 | 16 | */  | 
                                                        
| 17 | 17 | class PartitaIva  | 
                                                        
| 18 | 18 |  { | 
                                                        
| 19 | - /**  | 
                                                        |
| 20 | - * partita iva  | 
                                                        |
| 21 | - *  | 
                                                        |
| 22 | - * @var string  | 
                                                        |
| 23 | - */  | 
                                                        |
| 24 | - private $partitaIva;  | 
                                                        |
| 19 | + /**  | 
                                                        |
| 20 | + * partita iva  | 
                                                        |
| 21 | + *  | 
                                                        |
| 22 | + * @var string  | 
                                                        |
| 23 | + */  | 
                                                        |
| 24 | + private $partitaIva;  | 
                                                        |
| 25 | 25 | |
| 26 | - /**  | 
                                                        |
| 27 | - * @var boolean  | 
                                                        |
| 28 | - */  | 
                                                        |
| 29 | - private $isValid = false;  | 
                                                        |
| 26 | + /**  | 
                                                        |
| 27 | + * @var boolean  | 
                                                        |
| 28 | + */  | 
                                                        |
| 29 | + private $isValid = false;  | 
                                                        |
| 30 | 30 | |
| 31 | 31 | /**  | 
                                                        
| 32 | - * Sets the value of partitaIva.  | 
                                                        |
| 33 | - *  | 
                                                        |
| 34 | - * @param mixed $partitaIva the partita iva  | 
                                                        |
| 35 | - *  | 
                                                        |
| 36 | - * @return self  | 
                                                        |
| 37 | - */  | 
                                                        |
| 32 | + * Sets the value of partitaIva.  | 
                                                        |
| 33 | + *  | 
                                                        |
| 34 | + * @param mixed $partitaIva the partita iva  | 
                                                        |
| 35 | + *  | 
                                                        |
| 36 | + * @return self  | 
                                                        |
| 37 | + */  | 
                                                        |
| 38 | 38 | public function setPartitaIva($partitaIva)  | 
                                                        
| 39 | 39 |      { | 
                                                        
| 40 | 40 | $this->setIsValid(false);  | 
                                                        
| 41 | 41 | $this->partitaIva = $partitaIva;  | 
                                                        
| 42 | - $this->check();  | 
                                                        |
| 43 | - return $this;  | 
                                                        |
| 42 | + $this->check();  | 
                                                        |
| 43 | + return $this;  | 
                                                        |
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
| 46 | 46 | /**  | 
                                                        
| 47 | - * Sets the value of isValid.  | 
                                                        |
| 48 | - *  | 
                                                        |
| 49 | - * @param bool $isValid the is valid  | 
                                                        |
| 50 | - *  | 
                                                        |
| 51 | - * @return self  | 
                                                        |
| 52 | - */  | 
                                                        |
| 47 | + * Sets the value of isValid.  | 
                                                        |
| 48 | + *  | 
                                                        |
| 49 | + * @param bool $isValid the is valid  | 
                                                        |
| 50 | + *  | 
                                                        |
| 51 | + * @return self  | 
                                                        |
| 52 | + */  | 
                                                        |
| 53 | 53 | private function setIsValid(bool $isValid)  | 
                                                        
| 54 | 54 |      { | 
                                                        
| 55 | 55 | $this->isValid = $isValid;  | 
                                                        
| 56 | 56 | |
| 57 | - return $this;  | 
                                                        |
| 57 | + return $this;  | 
                                                        |
| 58 | 58 | }  | 
                                                        
| 59 | 59 | |
| 60 | 60 | /**  | 
                                                        
| 61 | - * Gets the value of partitaIva.  | 
                                                        |
| 62 | - *  | 
                                                        |
| 63 | - * @return mixed  | 
                                                        |
| 64 | - */  | 
                                                        |
| 61 | + * Gets the value of partitaIva.  | 
                                                        |
| 62 | + *  | 
                                                        |
| 63 | + * @return mixed  | 
                                                        |
| 64 | + */  | 
                                                        |
| 65 | 65 | public function getPartitaIva()  | 
                                                        
| 66 | 66 |      { | 
                                                        
| 67 | 67 | return $this->partitaIva;  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 | |
| 70 | 70 | /**  | 
                                                        
| 71 | - * Gets the value of isValid.  | 
                                                        |
| 72 | - *  | 
                                                        |
| 73 | - * @return bool  | 
                                                        |
| 74 | - */  | 
                                                        |
| 71 | + * Gets the value of isValid.  | 
                                                        |
| 72 | + *  | 
                                                        |
| 73 | + * @return bool  | 
                                                        |
| 74 | + */  | 
                                                        |
| 75 | 75 | public function isValid()  | 
                                                        
| 76 | 76 |      { | 
                                                        
| 77 | 77 | return $this->isValid;  | 
                                                        
@@ -84,35 +84,35 @@ discard block  | 
                                                    ||
| 84 | 84 | */  | 
                                                        
| 85 | 85 | private function check()  | 
                                                        
| 86 | 86 |      {    	 | 
                                                        
| 87 | - $partitaIva = $this->getPartitaIva();  | 
                                                        |
| 88 | -    	if ($partitaIva === "" || strlen($partitaIva) != 11 || (preg_match("/^[0-9]+\$/", $partitaIva) != 1)) { | 
                                                        |
| 89 | - $valid = false;  | 
                                                        |
| 90 | -    	} else {    		 | 
                                                        |
| 91 | - $s = 0;  | 
                                                        |
| 92 | -			for ($i = 0; $i <= 9; $i += 2) { | 
                                                        |
| 93 | -				$s += ord($partitaIva[$i]) - ord("0"); | 
                                                        |
| 94 | - }  | 
                                                        |
| 87 | + $partitaIva = $this->getPartitaIva();  | 
                                                        |
| 88 | +        if ($partitaIva === "" || strlen($partitaIva) != 11 || (preg_match("/^[0-9]+\$/", $partitaIva) != 1)) { | 
                                                        |
| 89 | + $valid = false;  | 
                                                        |
| 90 | +        } else {    		 | 
                                                        |
| 91 | + $s = 0;  | 
                                                        |
| 92 | +            for ($i = 0; $i <= 9; $i += 2) { | 
                                                        |
| 93 | +                $s += ord($partitaIva[$i]) - ord("0"); | 
                                                        |
| 94 | + }  | 
                                                        |
| 95 | 95 | |
| 96 | -			for ($i = 1; $i <= 9; $i += 2) { | 
                                                        |
| 97 | -				$c = 2 * ( ord($partitaIva[$i]) - ord("0") ); | 
                                                        |
| 98 | -				if ($c > 9) { | 
                                                        |
| 99 | - $c = $c - 9;  | 
                                                        |
| 100 | - }  | 
                                                        |
| 101 | - $s += $c;  | 
                                                        |
| 102 | - }  | 
                                                        |
| 96 | +            for ($i = 1; $i <= 9; $i += 2) { | 
                                                        |
| 97 | +                $c = 2 * ( ord($partitaIva[$i]) - ord("0") ); | 
                                                        |
| 98 | +                if ($c > 9) { | 
                                                        |
| 99 | + $c = $c - 9;  | 
                                                        |
| 100 | + }  | 
                                                        |
| 101 | + $s += $c;  | 
                                                        |
| 102 | + }  | 
                                                        |
| 103 | 103 | |
| 104 | -			if (((10 - $s%10)%10) !== (ord($partitaIva[10]) - ord("0"))) { | 
                                                        |
| 105 | - $valid = false;  | 
                                                        |
| 106 | - }  | 
                                                        |
| 104 | +            if (((10 - $s%10)%10) !== (ord($partitaIva[10]) - ord("0"))) { | 
                                                        |
| 105 | + $valid = false;  | 
                                                        |
| 106 | + }  | 
                                                        |
| 107 | 107 | |
| 108 | -			if (preg_match("/^0([0-9][1-9]|[1-9][0-9])|100|120|121|888|999/",substr($partitaIva,7,3))) { | 
                                                        |
| 109 | - $valid = true;  | 
                                                        |
| 110 | - }  | 
                                                        |
| 108 | +            if (preg_match("/^0([0-9][1-9]|[1-9][0-9])|100|120|121|888|999/",substr($partitaIva,7,3))) { | 
                                                        |
| 109 | + $valid = true;  | 
                                                        |
| 110 | + }  | 
                                                        |
| 111 | 111 | |
| 112 | -			if (!isset($valid)) { | 
                                                        |
| 113 | - $valid = false;  | 
                                                        |
| 114 | - }  | 
                                                        |
| 115 | - }  | 
                                                        |
| 116 | - $this->setIsValid($valid);  | 
                                                        |
| 112 | +            if (!isset($valid)) { | 
                                                        |
| 113 | + $valid = false;  | 
                                                        |
| 114 | + }  | 
                                                        |
| 115 | + }  | 
                                                        |
| 116 | + $this->setIsValid($valid);  | 
                                                        |
| 117 | 117 | }  | 
                                                        
| 118 | 118 | }  | 
                                                        
| 119 | 119 | \ No newline at end of file  | 
                                                        
@@ -94,7 +94,7 @@ discard block  | 
                                                    ||
| 94 | 94 | }  | 
                                                        
| 95 | 95 | |
| 96 | 96 |  			for ($i = 1; $i <= 9; $i += 2) { | 
                                                        
| 97 | -				$c = 2 * ( ord($partitaIva[$i]) - ord("0") ); | 
                                                        |
| 97 | +				$c = 2*(ord($partitaIva[$i]) - ord("0")); | 
                                                        |
| 98 | 98 |  				if ($c > 9) { | 
                                                        
| 99 | 99 | $c = $c - 9;  | 
                                                        
| 100 | 100 | }  | 
                                                        
@@ -105,7 +105,7 @@ discard block  | 
                                                    ||
| 105 | 105 | $valid = false;  | 
                                                        
| 106 | 106 | }  | 
                                                        
| 107 | 107 | |
| 108 | -			if (preg_match("/^0([0-9][1-9]|[1-9][0-9])|100|120|121|888|999/",substr($partitaIva,7,3))) { | 
                                                        |
| 108 | +			if (preg_match("/^0([0-9][1-9]|[1-9][0-9])|100|120|121|888|999/", substr($partitaIva, 7, 3))) { | 
                                                        |
| 109 | 109 | $valid = true;  | 
                                                        
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |