Skip to content

Commit

Permalink
fix: United Kingdom test and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 6, 2024
1 parent f86b0b6 commit ec2c3f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions spec/loophp/Tin/CountryHandler/UnitedKingdomSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class UnitedKingdomSpec extends AbstractAlgorithmSpec
{
public const INVALID_NUMBER_LENGTH = '12345678901';
public const INVALID_NUMBER_LENGTH = [ 'wwwwwwww', '12345678901' ];

public const INVALID_NUMBER_PATTERN = ['wwwwwwww', 'GB123456A'];
public const INVALID_NUMBER_PATTERN = ['wwwwwwwww', 'GB123456A'];

public const VALID_NUMBER = ['1234567890', 'AA123456A'];
}
14 changes: 6 additions & 8 deletions src/CountryHandler/UnitedKingdom.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ final class UnitedKingdom extends CountryHandler

public function getTIN(): string
{
$tin = parent::getTIN();

if (8 === strlen($tin)) {
$tin .= ' ';
}

return $tin;
return str_pad($this->normalizeTin(parent::getTIN()), 9, ' ', STR_PAD_RIGHT);
}

protected function hasValidLength(string $tin): bool
Expand All @@ -63,7 +57,11 @@ protected function hasValidPattern(string $tin): bool
return false;
}

return !($this->isFollowLength2($tin) && !$this->isFollowPattern2($tin));
if ($this->isFollowLength2($tin) && !$this->isFollowPattern2($tin)) {
return false;
}

return true;
}

private function isFollowLength1(string $tin): bool
Expand Down

0 comments on commit ec2c3f1

Please sign in to comment.