Ecma\Intl\Locale\Options

class Ecma\Intl\Locale\Options

Configuration for the locale.

Any property set on the Options object passed to the Locale’s constructor will override the same properties on the language tag passed to the Locale.

This class implements Iterator to allow instances for use in array unpacking scenarios. For example:

use Ecma\Intl\Locale\Options;
$commonOptions = new Options(hourCycle: 'h23');
$englishOptions = new Options(...[...$commonOptions, 'language' => 'en']);

Please note that null values will be skipped when unpacking or iterating over them. This facilitates scenarios where you might return JSON-encoded values to be used by Intl.Locale instances in JavaScript.

property calendar string | null, readonly

The calendar to set on the locale.

property caseFirst string | null, readonly

The case sorting algorithm to set on the locale.

property collation string | null, readonly

The collation algorithm to set on the locale.

property currency string | null, readonly

The currency to set on the locale.

property hourCycle string | null, readonly

The hour cycle to set on the locale.

property language string | null, readonly

The language to set on the locale.

property numberingSystem string | null, readonly

The numbering system to set on the locale.

property numeric bool | null, readonly

Whether to sort a sequence of decimal digits with its numeric value (i.e, "A-21" < "A-123").

property region string | null, readonly

The region to set on the locale.

property script string | null, readonly

The script to set on the locale.

__construct([$calendar = null[, $caseFirst = null[, $collation = null[, $hourCycle = null[, $language = null[, $numberingSystem = null[, $numeric = null[, $region = null[, $script = null]]]]]]]]])
Parameters:
  • $calendar (Stringable | string | null) – The calendar to use with the locale.

  • $caseFirst (Stringable | string | false | null) – The case sorting algorithm to use with the locale.

  • $collation (Stringable | string | null) – The collation algorithm to use with the locale.

  • $currency (Stringable | string | null) – The currency to set on the locale.

  • $hourCycle (Stringable | string | null) – The hour cycle to use with the locale.

  • $language (Stringable | string | null) – The language to use with the locale.

  • $numberingSystem (Stringable | string | null) – The numbering system to use with the locale.

  • $numeric (bool | null) – Whether to sort a sequence of decimal digits with its numeric value (i.e, "A-21" < "A-123").

  • $region (Stringable | string | null) – The region to use with the locale.

  • $script (Stringable | string | null) – The script to use with the locale.

jsonSerialize() object

Returns an object of these options, suitable for serializing to JSON.

Please note that any options with a null value will not be included in the object this method returns. This allows the JSON to be passed to JavaScript contexts, where these properties are considered undefined.

current() string | bool
next() void
key() string
valid() bool
rewind() void