Since: 2025-02-21

class ReceiptCode implements Stringable (View source)

This class represents a receipt code identified by code, prefix, ymd and number. The receipt code is generated from these properties.

Properties

$ymd

Year month day of the receipt code

$number

Number of the receipt code

$code

Receipt code

Methods

code(string $code)

Parse code and set code, prefix, ymd and number.

string
nextCode()

Get next code.

static ReceiptCode
of(string|null $code = null, string|null $prefix = 'PO')

Create a new instance of ReceiptCode.

string
__toString()

Get the string representation of the object.

Details

ReceiptCode code(string $code)

Parse code and set code, prefix, ymd and number.

Parameters

string $code ReceiptCode

Return Value

ReceiptCode

Provides a fluent interface

string nextCode()

Get next code.

Return Value

string

Next code

Examples

ReceiptCode::of()->nextCode() => PO-20250312-0001
ReceiptCode::of('PO-20250312-0001')->nextCode() => PO-20250312-0002
ReceiptCode::of('PO-20250312-9999')->nextCode() => PO-20250312-10000
ReceiptCode::of('PO-20250312-9999', prefix: 'CT')->nextCode() => CT-20250312-10000

static ReceiptCode of(string|null $code = null, string|null $prefix = 'PO')

Create a new instance of ReceiptCode.

Parameters

string|null $code

receipt code

string|null $prefix

prefix of the receipt code, default is 'PO'

Return Value

ReceiptCode

Provides a new instance of ReceiptCode

string __toString()

Get the string representation of the object.

Return Value

string

The method returns the code representation