Skip to content

Commit 45c0980

Browse files
committed
2 parents 442326a + c8c53e7 commit 45c0980

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/SerialNumberGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public function generate(int $count, ?int $serie = null, ?Carbon $date = null):
1919
return preg_replace_callback_array(
2020
[
2121
'/S+/' => function ($matches) use ($serie) {
22-
if (!$matches[0]) {
22+
if (! $matches[0]) {
2323
return '';
2424
}
2525
$slotLength = strlen($matches[0]);
26-
throw_if(!$serie, "The serial Number format includes a $slotLength long Serie (S), but no serie has been passed");
26+
throw_if(! $serie, "The serial Number format includes a $slotLength long Serie (S), but no serie has been passed");
2727

2828
$serieLength = strlen(strval($serie));
2929
throw_if(
@@ -41,7 +41,7 @@ public function generate(int $count, ?int $serie = null, ?Carbon $date = null):
4141
'/M+/' => fn ($matches) => $matches[0] && $date ? substr($date->format('m'), -strlen($matches[0])) : '',
4242
'/Y+/' => fn ($matches) => $matches[0] && $date ? substr($date->format('Y'), -strlen($matches[0])) : '',
4343
'/C+/' => function ($matches) use ($count) {
44-
if (!$matches[0]) {
44+
if (! $matches[0]) {
4545
return '';
4646
}
4747
throw_if(
@@ -58,7 +58,7 @@ public function generate(int $count, ?int $serie = null, ?Carbon $date = null):
5858
},
5959
// Must be kept last to avoid interfering with other callbacks
6060
'/P+/' => function ($matches) {
61-
if (!$matches[0]) {
61+
if (! $matches[0]) {
6262
return '';
6363
}
6464
$slotLength = strlen($matches[0]);

tests/Unit/SerialNumberTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313

1414
expect($serialNumber)->toBe($expected);
1515
})->with([
16-
['PP-YYCCCC', "IN", null, 2, 'IN-220002'],
16+
['PP-YYCCCC', 'IN', null, 2, 'IN-220002'],
1717
['SSSS-YYCCCC', null, 1, 2, '0001-220002'],
1818
['SSSS-CCCC', null, 1, 2, '0001-0002'],
1919
['SSCC', null, 1, 2, '0102'],
2020
['CCCC', null, 1, 2, '0002'],
21-
['SSSSPP-YYCCCC', "IN", 1, 2, '0001IN-220002'],
22-
['YYSSSSPPCCCC', "IN", 1, 2, '220001IN0002'],
23-
['YYCCCCSSSSPP', "IN", 1, 2, '2200020001IN'],
24-
['PPSSSS-YYYYCCCC', "IN", 1, 2, 'IN0001-20220002'],
25-
['PPSSSS-YYYCCCC', "IN", 1, 2, 'IN0001-0220002'],
26-
['PPCCCC', "IN", null, 102, 'IN0102'],
27-
['PPSSSS-YYCCCC', "YC", 1, 2, 'YC0001-220002'],
28-
['PPSSSS-YYCCCC', "PS", 1, 2, 'PS0001-220002'],
21+
['SSSSPP-YYCCCC', 'IN', 1, 2, '0001IN-220002'],
22+
['YYSSSSPPCCCC', 'IN', 1, 2, '220001IN0002'],
23+
['YYCCCCSSSSPP', 'IN', 1, 2, '2200020001IN'],
24+
['PPSSSS-YYYYCCCC', 'IN', 1, 2, 'IN0001-20220002'],
25+
['PPSSSS-YYYCCCC', 'IN', 1, 2, 'IN0001-0220002'],
26+
['PPCCCC', 'IN', null, 102, 'IN0102'],
27+
['PPSSSS-YYCCCC', 'YC', 1, 2, 'YC0001-220002'],
28+
['PPSSSS-YYCCCC', 'PS', 1, 2, 'PS0001-220002'],
2929
]);
3030

3131
it('can parse serial number from format', function ($format, $serialNumber, $prefix, $serie, $year, $count) {

0 commit comments

Comments
 (0)