Skip to content

Commit

Permalink
Fixed the parameter typefrom int to string: validation error when sta…
Browse files Browse the repository at this point in the history
…rts with zeroes
  • Loading branch information
bernardofm committed Nov 23, 2022
1 parent 65f4ae8 commit de3415b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Generator
*
* @throws \Lloricode\CheckDigit\Exceptions\ValidationException
*/
public function __construct(int $numbers, string $format = self::GTIN_13)
public function __construct(string $numbers, string $format = self::GTIN_13)
{
$this->checkDigit = self::execute($numbers, $format);
$this->value = ($numbers * 10) + $this->checkDigit;
Expand All @@ -55,7 +55,7 @@ public function __construct(int $numbers, string $format = self::GTIN_13)
*
* @throws \Lloricode\CheckDigit\Exceptions\ValidationException
*/
private static function validateLength(int $number, string $format): void
private static function validateLength(string $number, string $format): void
{
$actualLength = strlen((string)$number);
if (self::ID_KEY_FORMATS_LENGTH[$format] != ($actualLength + 1)) {
Expand Down Expand Up @@ -102,7 +102,7 @@ private static function nearestEqualOrHigherThenMultiplyByTen(int $number): int
* @return int
* @throws \Lloricode\CheckDigit\Exceptions\ValidationException
*/
private static function execute(int $numbers, string $format = self::GTIN_13): int
private static function execute(string $numbers, string $format = self::GTIN_13): int
{
self::validateFormat($format);
self::validateLength($numbers, $format);
Expand Down

0 comments on commit de3415b

Please sign in to comment.