Since: 2025-02-04

class GoodCode (View source)

This class makes a set code, option code and so on.

Methods

__construct(string $code, GoodCodeType $originType)

Constructor.

string
code()

Gets the code property

GoodCodeType
originalType()

Gets the originalType property

GoodCodeType
type()

Gets the type property

int|string|array
value()

Output value for good code.

static int
getId(string $code)

Get ID from GIF and COM codes.

static GoodCode
of(string $code, string|null $option = null, callable|null $callback = null)

Create GoodCode instance from given code string and callback function

static GoodCode
setCodeOf(array $setCodes)

Make SetCode from key-value set code array.

Details

__construct(string $code, GoodCodeType $originType)

Constructor.

Parameters

string $code

The code

GoodCodeType $originType

The type of the code

string code()

Gets the code property

Return Value

string

GoodCodeType originalType()

Gets the originalType property

Return Value

GoodCodeType

GoodCodeType type()

Gets the type property

Return Value

GoodCodeType

int|string|array value()

Output value for good code.

If the code is set code, it will be array of good values. If the code is normal code, it will be good code string. the code shouldn't be option, complex and gift code.

Return Value

int|string|array

Exceptions

BadFunctionCallException

static int getId(string $code)

Get ID from GIF and COM codes.

Parameters

string $code

GIF or COM code

Return Value

int

The method returns ID

static GoodCode of(string $code, string|null $option = null, callable|null $callback = null)

Create GoodCode instance from given code string and callback function

Parameters

string $code

good_code, set_code, option_code

string|null $option

option_good_option name

callable|null $callback

Function to call

Return Value

GoodCode

The method returns GoodCode instance.

static GoodCode setCodeOf(array $setCodes)

Make SetCode from key-value set code array.

Parameters

array $setCodes

key-value set code array

Return Value

GoodCode

The method returns GoodCode instance with the SetCode array

Examples

GoodCode::setCodeOf(['7369'=>4,'4235'=>6])