PHP Class Hal\Resource

Inheritance: extends AbstractHal
Show file Open project: zircote/hal Class Usage Examples

Protected Properties

Property Type Description
$_data array Internal storage of primitive types
$_embedded array Internal storage of Resource objects
$_links array Internal storage of Link objects
$jsonNumericCheck boolean

Public Methods

Method Description
__construct ( string | SelfLink $href, array $data = [], string | null $title = null, string | null $name = null, string | null $hreflang = null )
__toJson ( ) : string
__toString ( ) : string
getLinks ( ) : array
getSelf ( ) : Link
getXML ( SimpleXMLElemen\SimpleXMLElement | null $xml = null ) : SimpleXMLElement
setData ( $rel, null $data = null ) : Resource
setEmbedded ( string $rel, Resource $resource = null, boolean $singular = false ) : Resource
setJsonNumericCheck ( boolean $jsonNumericCheck = self::JSON_NUMERIC_CHECK_OFF ) : Resource Sets the ability to perform numeric to int conversion of the JSON output.
setLink ( Link $link, boolean $singular = false, boolean $plural = false ) : Resource Add a link to the resource.
setLinks ( array $links, boolean $singular = false, boolean $plural = false ) : Resource Convenience function to set multiple links at once
setXML ( SimpleXMLElement $xml ) : Resource
toArray ( ) : array

Protected Methods

Method Description
_addData ( SimpleXMLElement $xml, array $data, string $keyOverride = null )
_addLink ( Link $link ) : Resource
_addLinks ( Link $link )
_getEmbRes ( Resource $embed ) : SimpleXMLElement
_getEmbedded ( mixed $embedded, string | null $_rel = null )
_recurseEmbedded ( Resource | null | array $embeded )
_recurseLinks ( array | Link $links )
createLink ( $href, $title, $name, $hreflang ) : Link

Method Details

__construct() public method

public __construct ( string | SelfLink $href, array $data = [], string | null $title = null, string | null $name = null, string | null $hreflang = null )
$href string | SelfLink
$data array
$title string | null
$name string | null
$hreflang string | null

__toJson() public method

public __toJson ( ) : string
return string

__toString() public method

public __toString ( ) : string
return string

_addData() protected method

protected _addData ( SimpleXMLElement $xml, array $data, string $keyOverride = null )
$xml SimpleXMLElement
$data array
$keyOverride string

_getEmbRes() protected method

protected _getEmbRes ( Resource $embed ) : SimpleXMLElement
$embed Resource
return SimpleXMLElement

_getEmbedded() protected method

protected _getEmbedded ( mixed $embedded, string | null $_rel = null )
$embedded mixed
$_rel string | null

_recurseEmbedded() protected method

protected _recurseEmbedded ( Resource | null | array $embeded )
$embeded Resource | null | array

getSelf() public method

public getSelf ( ) : Link
return Link

getXML() public method

public getXML ( SimpleXMLElemen\SimpleXMLElement | null $xml = null ) : SimpleXMLElement
$xml SimpleXMLElemen\SimpleXMLElement | null
return SimpleXMLElement

setData() public method

public setData ( $rel, null $data = null ) : Resource
$rel
$data null
return Resource

setEmbedded() public method

public setEmbedded ( string $rel, Resource $resource = null, boolean $singular = false ) : Resource
$rel string
$resource Resource
$singular boolean
return Resource

setJsonNumericCheck() public method

Example Usage: $hal->setJsonNumericCheck($jsonNumericCheck = self::JSON_NUMERIC_CHECK_OFF); $hal->setJsonNumericCheck($jsonNumericCheck = self::JSON_NUMERIC_CHECK_ON);
public setJsonNumericCheck ( boolean $jsonNumericCheck = self::JSON_NUMERIC_CHECK_OFF ) : Resource
$jsonNumericCheck boolean
return Resource

setXML() public method

public setXML ( SimpleXMLElement $xml ) : Resource
$xml SimpleXMLElement
return Resource

toArray() public method

public toArray ( ) : array
return array

Property Details

$_data protected property

Internal storage of primitive types
protected array $_data
return array

$_embedded protected property

Internal storage of Resource objects
protected array $_embedded
return array

$jsonNumericCheck protected property

protected bool $jsonNumericCheck
return boolean