Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ReceiptCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ public function nextCode(): string
/**
* Create a new instance of ReceiptCode.
*
* @param string $code ReceiptCode
* @param string|null $code ReceiptCode
* @return static Provides a new instance of ReceiptCode
*/
public static function of(string $code): self
public static function of(?string $code = null): self
{
return new self($code);
return is_null($code) ? self::make() : new self($code);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/ReceiptCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ public function test_next_code_method()
public function test_no_code()
{
$this->assertEquals('PO-'.date('Ymd').'-0001', ReceiptCode::make()->nextCode());

$this->assertEquals('PO-'.date('Ymd').'-0001', ReceiptCode::of()->nextCode());
}
}