Skip to content

Commit

Permalink
refactor: Get rid of PHPStan issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 11, 2021
1 parent b38dce3 commit 8c3faca
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
parameters:
ignoreErrors:
-
message: "#Casting to array<int, string> something that\\'s already array<int, string>.#"
paths:
- src/CountryHandler/CountryHandler.php
- src/CountryHandler/Germany.php
2 changes: 1 addition & 1 deletion src/CountryHandler/Austria.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function hasValidRule(string $tin): bool
$c8 = $this->digitAt($tin, 7);
$c9 = $this->digitAt($tin, 8);

$sum = (int) array_sum([
$sum = array_sum([
$c1,
$c3,
$c5,
Expand Down
8 changes: 3 additions & 5 deletions src/CountryHandler/CountryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function digitAt(string $str, int $index): int
protected function digitsSum(int $int): int
{
return array_reduce(
(array) str_split((string) $int),
str_split((string) $int),
static function (int $carry, string $digit): int {
return $carry + (int) $digit;
},
Expand All @@ -106,14 +106,12 @@ static function (int $carry, string $digit): int {
*/
protected function getAlphabeticalPosition(string $character): int
{
return false !== ($return = array_combine(range('a', 'z'), range(1, 26))) ?
$return[strtolower($character)] :
0;
return 1 + array_flip(range('a', 'z'))[strtolower($character)];
}

protected function getLastDigit(int $number): int
{
$split = (array) str_split((string) $number);
$split = str_split((string) $number);

return (int) end($split);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CountryHandler/Germany.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function hasValidRule(string $tin): bool

private function calculateCheckDigit(string $tin): int
{
$chars = (array) str_split($tin);
$chars = str_split($tin);
$remainder_mod_eleven = 10;

for ($length = strlen($tin), $counter = 0; $length - 1 > $counter; ++$counter) {
Expand Down

0 comments on commit 8c3faca

Please sign in to comment.