Skip to content

Commit

Permalink
Usage of a function in loops should be avoided.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardonavarrom committed Oct 9, 2016
1 parent d7e4173 commit 877e256
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/VATINValidator/Validator/VATINValidatorES.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public function validate($vatin, $allowLowerCase = true)
private function getCIFPairSum($centralDigits)
{
$pairSum = 0;
for ($i = 1; $i < strlen($centralDigits); $i += 2) {
$centralDigitsNum = strlen($centralDigits);
for ($i = 1; $i < $centralDigitsNum; $i += 2) {
$pairSum += (int)$centralDigits[$i];
}

Expand All @@ -78,7 +79,8 @@ private function getCIFPairSum($centralDigits)
private function getCIFOddDoubleSum($centralDigits)
{
$oddDoubleSum = 0;
for ($i = 0; $i < strlen($centralDigits); $i += 2) {
$centralDigitsNum = strlen($centralDigits);
for ($i = 0; $i < $centralDigitsNum; $i += 2) {
$oddDoubleSum += (int)array_sum(str_split($centralDigits[$i] * 2));
}

Expand Down

0 comments on commit 877e256

Please sign in to comment.