PHP Class FluentDOM\Loader\Json\JsonDOM

Inheritance: implements FluentDOM\Loadable, use trait FluentDOM\Loader\Supports\Json
Datei anzeigen Open project: fluentdom/fluentdom

Public Methods

Method Description
__construct ( integer $options, integer $depth = 100 ) Create the loader for a json string.
getSupported ( ) : string[]
getTypeFromValue ( mixed $value ) : string Get the type from a variable value.
getValueAsString ( string $type, mixed $value ) : null | string
load ( mixed $source, string $contentType, array | Traversable | Options $options = [] ) : Document | Result | null Load the json string into an DOMDocument
loadFragment ( string $source, string $contentType, array | Traversable | Options $options = [] ) : DocumentFragment | null
onMapKey ( null | FALSE | callable $callback = NULL ) : callable | null Get/Set a mapping callback for the tag names. If it is a callable it will be set. FALSE removes the callback.

Protected Methods

Method Description
transferTo ( DOMNode $target, mixed $value, integer $recursions = 100 ) Transfer a value into a target xml element node. This sets attributes on the target node and creates child elements for object and array values.

Private Methods

Method Description
getQualifiedName ( string $key, string $default, boolean $isArrayElement = FALSE ) : string Get a valid qualified name (tag name) using the property name/key.
transferArrayTo ( DOMNode $target, array $value, integer $recursions ) Transfer an array value into a target element node. Sets the json:type attribute to 'array' and creates child element nodes for each array element using the default QName.
transferObjectTo ( DOMNode $target, object $value, integer $recursions ) Transfer an object value into a target element node. If the object has no properties, the json:type attribute is always set to 'object'. If verbose is not set the json:type attribute will be omitted if the object value has properties.

Method Details

__construct() public method

The string will be decoded into a php variable structure and convert into a DOM document If options contains is self::OPTION_VERBOSE, the DOMNodes will all have json:type and json:name attributes. Even if the information could be read from the structure.
public __construct ( integer $options, integer $depth = 100 )
$options integer
$depth integer

getSupported() public method

public getSupported ( ) : string[]
return string[]

getTypeFromValue() public method

Get the type from a variable value.
public getTypeFromValue ( mixed $value ) : string
$value mixed
return string

getValueAsString() public method

public getValueAsString ( string $type, mixed $value ) : null | string
$type string
$value mixed
return null | string

load() public method

Load the json string into an DOMDocument
public load ( mixed $source, string $contentType, array | Traversable | Options $options = [] ) : Document | Result | null
$source mixed
$contentType string
$options array | Traversable | Options
return FluentDOM\Document | FluentDOM\Loader\Result | null

loadFragment() public method

public loadFragment ( string $source, string $contentType, array | Traversable | Options $options = [] ) : DocumentFragment | null
$source string
$contentType string
$options array | Traversable | Options
return FluentDOM\DocumentFragment | null

onMapKey() public method

function callback(string $key, boolean $isArrayElement) }
public onMapKey ( null | FALSE | callable $callback = NULL ) : callable | null
$callback null | FALSE | callable
return callable | null

transferTo() protected method

If the current element is an object or array the method is called recursive. The $recursions parameter is used to limit the recursion depth of this function.
protected transferTo ( DOMNode $target, mixed $value, integer $recursions = 100 )
$target DOMNode
$value mixed
$recursions integer