Skip to content

Commit

Permalink
Merge pull request #37 from DavidePastore/remove-curly-braces-access-…
Browse files Browse the repository at this point in the history
…to-string

Remove curly braces access to string
  • Loading branch information
DavidePastore authored Feb 22, 2020
2 parents 2f8ddc2 + d517b01 commit f0bc8da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4

matrix:
allow_failures:
Expand All @@ -13,7 +14,7 @@ matrix:

before_script:
- composer self-update
- composer update --prefer-source
- composer install

script:
- vendor/bin/phpunit --testsuite travis-ci
Expand Down
2 changes: 1 addition & 1 deletion src/CodiceFiscale/AbstractCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected function calculateSumByDictionary($temporaryCodiceFiscale, $dictionary
{
$sum = 0;
for (; $i < 15; $i = $i + 2) {
$k = $temporaryCodiceFiscale{$i};
$k = $temporaryCodiceFiscale[$i];
$sum = $sum + $dictionaryArray[$k];
}

Expand Down
4 changes: 2 additions & 2 deletions src/CodiceFiscale/Calculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ private function calculateOmocodia($temporaryCodiceFiscale)
private function replaceOmocodiaSection($divider, $temporaryCodiceFiscale, $startingIndex, $endingIndex, $characterIndex)
{
if ($this->omocodiaLevel % $divider >= $startingIndex && $this->omocodiaLevel % $divider <= $endingIndex) {
$k = $temporaryCodiceFiscale{$characterIndex};
$k = $temporaryCodiceFiscale[$characterIndex];
$newChar = $this->omocodiaCodes[$k];
$temporaryCodiceFiscale{$characterIndex} = $newChar;
$temporaryCodiceFiscale[$characterIndex] = $newChar;
}
return $temporaryCodiceFiscale;
}
Expand Down
4 changes: 2 additions & 2 deletions src/CodiceFiscale/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ private function validateAndReplaceOmocodia()
private function replaceOmocodiaSection($divider, $startingIndex, $endingIndex, $characterIndex)
{
if ($this->foundOmocodiaLevel % $divider >= $startingIndex && $this->foundOmocodiaLevel % $divider <= $endingIndex) {
$charToCheck = $this->codiceFiscaleWithoutOmocodia{$characterIndex};
$charToCheck = $this->codiceFiscaleWithoutOmocodia[$characterIndex];
if (!in_array($charToCheck, $this->omocodiaCodes)) {
throw new Exception('The codice fiscale to validate has an invalid character');
}
$newChar = array_search($charToCheck, $this->omocodiaCodes);
$this->codiceFiscaleWithoutOmocodia{$characterIndex} = $newChar;
$this->codiceFiscaleWithoutOmocodia[$characterIndex] = $newChar;
}
}

Expand Down

0 comments on commit f0bc8da

Please sign in to comment.