File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,12 +82,12 @@ public function nextCode(): string
8282 /**
8383 * Create a new instance of ReceiptCode.
8484 *
85- * @param string $code ReceiptCode
85+ * @param string|null $code ReceiptCode
8686 * @return static Provides a new instance of ReceiptCode
8787 */
88- public static function of (string $ code ): self
88+ public static function of (? string $ code = null ): self
8989 {
90- return new self ($ code );
90+ return is_null ( $ code ) ? self :: make () : new self ($ code );
9191 }
9292
9393 /**
Original file line number Diff line number Diff line change @@ -29,5 +29,7 @@ public function test_next_code_method()
2929 public function test_no_code ()
3030 {
3131 $ this ->assertEquals ('PO- ' .date ('Ymd ' ).'-0001 ' , ReceiptCode::make ()->nextCode ());
32+
33+ $ this ->assertEquals ('PO- ' .date ('Ymd ' ).'-0001 ' , ReceiptCode::of ()->nextCode ());
3234 }
3335}
You can’t perform that action at this time.
0 commit comments