Since: 2025-02-24

class Sku implements Stringable (View source)

This class represents a SKU identified by code and prefix. The SKU is generated from these properties.

Methods

string
sku()

Get the SKU.

static Sku
of(string|int|array $code, string|null $prefix = null)

Create a new SKU instance.

string
__toString()

Get the string representation of the SKU.

Details

string sku()

Get the SKU.

Return Value

string

The method returns the SKU

Examples

print Sku::of(123, prefix: 'BO');    => 'BO123'

static Sku of(string|int|array $code, string|null $prefix = null)

Create a new SKU instance.

Parameters

string|int|array $code

The SKU

string|null $prefix

Prefix for the SKU

Return Value

Sku

Provides fluent interface

Exceptions

InvalidArgumentException

string __toString()

Get the string representation of the SKU.

Return Value

string

The magic method returns the SKU

Examples

print Sku::of('1') => 'A1'
print Sku::of('1', prefix: 'BO') => 'BO1'