Skip to content

Commit

Permalink
Fix codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbraunc24 authored and drupol committed Jul 17, 2024
1 parent 1b1bd2a commit 861c59a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions spec/loophp/Tin/CountryHandler/SlovakiaSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class SlovakiaSpec extends AbstractAlgorithmSpec
{
public const INVALID_NUMBER_LENGTH = '77111674201';

public const INVALID_SYNTAX = '2812030541';

public const VALID_NUMBER = '7711167420';

public const VALID_NUMBER2 = '281203054';

public const VALID_NUMBER3 = '2822030541';

public const INVALID_SYNTAX = '2812030541';
}
28 changes: 16 additions & 12 deletions src/CountryHandler/Slovakia.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace loophp\Tin\CountryHandler;

use function strlen;

/**
* Slovakia.
*/
Expand All @@ -26,26 +28,28 @@ final class Slovakia extends CountryHandler

public const PATTERN = '([1-9]\\d[234789]\\d{7})|(\\d{2}[0156]\\d[0-3]\\d{4,5})';

protected function hasValidLength(string $tin): bool
{
$c1c2 = substr($tin, 0, 2);

if (54 > $c1c2) {
return $this->matchLength($tin, self::LENGTH) || $this->matchLength($tin, self::LENGTH - 1);
}

return parent::hasValidLength($tin);
}

public function hasValidRule(string $tin): bool
{
if (strlen($tin) === 10
&& (int) $tin % 11 === 0) {
return true;
}

if (strlen($tin) === 10) {
return ((int) substr($tin, 0, 9) % 11) % 10 === (int) substr($tin, 9, 1);
return (int) substr($tin, 9, 1) === ((int) substr($tin, 0, 9) % 11) % 10;
}

return strlen($tin) === 9;
}

protected function hasValidLength(string $tin): bool
{
$c1c2 = substr($tin, 0, 2);

if (54 > $c1c2) {
return $this->matchLength($tin, self::LENGTH) || $this->matchLength($tin, self::LENGTH - 1);
}

return parent::hasValidLength($tin);
}
}

0 comments on commit 861c59a

Please sign in to comment.