22
33namespace Finller \Invoice ;
44
5- use Carbon \Carbon ;
6-
75class SerialNumberGenerator implements GenerateSerialNumber
86{
97 public function __construct (
@@ -17,17 +15,17 @@ public function __construct(
1715 public function generate (
1816 int $ count ,
1917 int $ serie = null ,
20- string |int | null $ year = null ,
21- string |int | null $ month = null ,
18+ string |int $ year = null ,
19+ string |int $ month = null ,
2220 ): string {
2321 return preg_replace_callback_array (
2422 [
2523 '/S+/ ' => function ($ matches ) use ($ serie ) {
26- if (!$ matches [0 ]) {
24+ if (! $ matches [0 ]) {
2725 return '' ;
2826 }
2927 $ slotLength = strlen ($ matches [0 ]);
30- throw_if (!$ serie , "The serial Number format includes a $ slotLength long Serie (S), but no serie has been passed " );
28+ throw_if (! $ serie , "The serial Number format includes a $ slotLength long Serie (S), but no serie has been passed " );
3129
3230 $ serieLength = strlen (strval ($ serie ));
3331 throw_if (
@@ -45,7 +43,7 @@ public function generate(
4543 '/M+/ ' => fn ($ matches ) => $ matches [0 ] && $ month ? substr ((string ) $ month , -strlen ($ matches [0 ])) : '' ,
4644 '/Y+/ ' => fn ($ matches ) => $ matches [0 ] && $ year ? substr ((string ) $ year , -strlen ($ matches [0 ])) : '' ,
4745 '/C+/ ' => function ($ matches ) use ($ count ) {
48- if (!$ matches [0 ]) {
46+ if (! $ matches [0 ]) {
4947 return '' ;
5048 }
5149 throw_if (
@@ -62,7 +60,7 @@ public function generate(
6260 },
6361 // Must be kept last to avoid interfering with other callbacks
6462 '/P+/ ' => function ($ matches ) {
65- if (!$ matches [0 ]) {
63+ if (! $ matches [0 ]) {
6664 return '' ;
6765 }
6866 $ slotLength = strlen ($ matches [0 ]);
0 commit comments