Skip to content

Commit

Permalink
Add type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed May 26, 2024
1 parent 099f441 commit 81877e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/Rules/Iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function isValid(mixed $value): bool
* @param string $iban
* @return int
*/
private function getChecksum(string $iban)
private function getChecksum(string $iban): int
{
$iban = substr($iban, 4) . substr($iban, 0, 4);
$iban = str_replace(
Expand All @@ -166,9 +166,9 @@ private function getChecksum(string $iban)
* Returns the designated length of IBAN for given IBAN
*
* @param string $iban
* @return int
* @return int|false
*/
private function getDesignatedIbanLength(string $iban)
private function getDesignatedIbanLength(string $iban): int|false
{
$countrycode = substr($iban, 0, 2);

Expand Down
4 changes: 2 additions & 2 deletions src/Rules/Isbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function isValid(mixed $value): bool
* @param string $value
* @return bool
*/
private function shortChecksumMatches(string $value)
private function shortChecksumMatches(string $value): bool
{
return $this->getShortChecksum($value) % 11 === 0;
}
Expand All @@ -57,7 +57,7 @@ private function shortChecksumMatches(string $value)
* @param string $value
* @return int
*/
private function getShortChecksum(string $value)
private function getShortChecksum(string $value): int
{
$checksum = 0;
$multiplier = 10;
Expand Down
8 changes: 4 additions & 4 deletions src/Rules/Isin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function isValid(mixed $value): bool
* @param string $value
* @return string
*/
public function normalize(string $value)
public function normalize(string $value): string
{
return $this->replaceChars($this->getValueWithoutLastDigit($value)) . $this->getLastDigit($value);
}
Expand All @@ -68,7 +68,7 @@ public function normalize(string $value)
* @param string $value
* @return string
*/
private function replaceChars(string $value)
private function replaceChars(string $value): string
{
return str_replace($this->chars, array_keys($this->chars), $value);
}
Expand All @@ -79,7 +79,7 @@ private function replaceChars(string $value)
* @param string $value
* @return string
*/
private function getValueWithoutLastDigit(string $value)
private function getValueWithoutLastDigit(string $value): string
{
return substr($value, 0, -1);
}
Expand All @@ -90,7 +90,7 @@ private function getValueWithoutLastDigit(string $value)
* @param string $value
* @return string
*/
private function getLastDigit(string $value)
private function getLastDigit(string $value): string
{
return substr($value, -1);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rules/Postalcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class Postalcode extends AbstractRule implements DataAwareRule
*
* @var ?string
*/
protected $reference;
protected ?string $reference;

/**
* Data set used for validation
*
* @var array<string>
*/
protected $data = [];
protected array $data = [];

/**
* Create a new rule instance with allowed countrycodes
Expand Down

0 comments on commit 81877e6

Please sign in to comment.