Translates JSON into objects and objects into JSON

 Methods

Create JSON mapper

__construct() 

Create object from json

fromJson(array $jsonArray) 

access public

Parameters

$jsonArray

Create object from json string

fromJsonString(string $jsonstring) 

access public

Parameters

$jsonstring

string

Returns the content type of mapped objects

getContentType() : string

Returns

string

Create object from string

mapFromStorage(string $string) : \Moneybird\Mapper_Mapable

access public

Parameters

$string

string

Returns

Map object

mapToStorage(\Moneybird\Mapper_Mapable $subject) : string

access public

Parameters

$subject

\Moneybird\Mapper_Mapable

Object to map

Returns

string

Convert to Json

toJson(\Moneybird\Mapper_Mapable $subject) : \Moneybird\SimpleXMLElement

access public

Parameters

$subject

\Moneybird\Mapper_Mapable

Object to map to Json

Returns

Convert to json string

toJsonString(\Moneybird\Mapper_Mapable $subject) : string

access public

Parameters

$subject

\Moneybird\Mapper_Mapable

Object to map to json

Returns

string

Map key to classname

jsonKeyToClassname(string $jsonKey) : string

access protected

Parameters

$jsonKey

string

Returns

string

Write key as property

keyToProperty(string $key) : string

access protected

Parameters

$key

string

Returns

string

Callback to rewrite key to property

keyToPropertyCallback(Array $match) : string

access protected

Parameters

$match

Array

Returns

string

Maps object to Json element-name

mapObjectToElementName(\Moneybird\Mapper_Mapable $subject) : string

access protected

Parameters

$subject

\Moneybird\Mapper_Mapable

Object to map to Json

Returns

string

Write property as xml key

propertyToKey(string $key) : string

access protected

Parameters

$key

string

Returns

string

Callback to rewrite property to key

propertyToKeyCallback(Array $match) : string

access protected

Parameters

$match

Array

Returns

string

Compare length of $a with length of $b

sortKeyLength(string $a, string $b) : int

Parameters

$a

string

$b

string

Returns

int

Test if $str ends with $end

strEndsWith(string $str, string $end) : bool

access protected

Parameters

$str

string

$end

string

Returns

bool

 Properties

 

Mapper for json element names to class names

$objectMapper : Array