class Encoder

Properties

callable[] $objectEncoders
callable[] $typeEncoders

Methods

__construct()

Constructor

string
encode(mixed $value)

Encode a value into JavaScript

string
encodeArray(array $array)

Encode an array to JavaScript

string
encodeAssociativeArray(array $array, bool $preserveNames = false)

Encode an associative array to JavaScript

string
encodeBoolean(bool $value)

Encode a boolean value into JavaScript

string
encodeCode(Code $code)

Encode a Code instance into JavaScript

string
encodeConfigValue(ConfigValue $configValue)

Encode a ConfigValue instance into JavaScript

string
encodeDictionary(Dictionary $dict)

Encode a Dictionary object into a JavaScript object

string
encodeIndexedArray(array $array)

Encode an indexed array to JavaScript

string
encodeObject(object $object)

Encode an object into JavaScript

string
encodePropertyName(string $name, bool $preserveNames)

Encode an object property name into JavaScript

string
encodeRegexp(Regexp $regexp)

Encode a Regexp object into JavaScript

string
encodeScalar(mixed $value)

Encode a scalar value into JavaScript

bool
isIndexedArray(array $array)

Test whether given array is a numerically indexed array

bool
isLegalProp(string $name)

Test whether a string can be used as a property name, unquoted

Details

at line 33
__construct()

Constructor

Will set up the default encoders

at line 58
string encode(mixed $value)

Encode a value into JavaScript

Parameters

mixed $value

Return Value

string

at line 75
protected string encodeArray(array $array)

Encode an array to JavaScript

Parameters

array $array

Return Value

string

at line 87
protected string encodeAssociativeArray(array $array, bool $preserveNames = false)

Encode an associative array to JavaScript

Parameters

array $array
bool $preserveNames

Return Value

string

at line 108
protected string encodeBoolean(bool $value)

Encode a boolean value into JavaScript

Parameters

bool $value

Return Value

string

at line 119
protected string encodeCode(Code $code)

Encode a Code instance into JavaScript

Parameters

Code $code

Return Value

string

at line 130
protected string encodeConfigValue(ConfigValue $configValue)

Encode a ConfigValue instance into JavaScript

Parameters

ConfigValue $configValue

Return Value

string

at line 141
protected string encodeDictionary(Dictionary $dict)

Encode a Dictionary object into a JavaScript object

Parameters

Dictionary $dict

Return Value

string

at line 152
protected string encodeIndexedArray(array $array)

Encode an indexed array to JavaScript

Parameters

array $array

Return Value

string

at line 163
protected string encodeObject(object $object)

Encode an object into JavaScript

Parameters

object $object

Return Value

string

at line 183
protected string encodePropertyName(string $name, bool $preserveNames)

Encode an object property name into JavaScript

Parameters

string $name
bool $preserveNames

Return Value

string

at line 194
protected string encodeRegexp(Regexp $regexp)

Encode a Regexp object into JavaScript

Parameters

Regexp $regexp

Return Value

string

at line 205
protected string encodeScalar(mixed $value)

Encode a scalar value into JavaScript

Parameters

mixed $value

Return Value

string

at line 216
protected bool isIndexedArray(array $array)

Test whether given array is a numerically indexed array

Parameters

array $array

Return Value

bool

at line 239
protected bool isLegalProp(string $name)

Test whether a string can be used as a property name, unquoted

Parameters

string $name

Property's name

Return Value

bool