PHP Class Essence\Media

This class is useful to ensure that any response from any provider will follow the same conventions.
Inheritance: implements IteratorAggregat\IteratorAggregate, implements JsonSerializabl\JsonSerializable
Show file Open project: essence/essence Class Usage Examples

Protected Properties

Property Type Description
$_properties array These default properties are gathered from the OEmbed and OpenGraph protocols, and provide all the basic informations needed to embed a media.

Public Methods

Method Description
__construct ( array $properties = [] ) Constructs a Media from the given dataset.
__get ( $property )
__isset ( $property )
__set ( $property, $value )
configure ( array $properties ) Merges the given properties with the current ones.
filledProperties ( ) : array Returns the filled properties.
get ( string $property, mixed $default = null ) : mixed Returns the value of the given property.
getIterator ( ) : ArrayIterator Returns an iterator for the media properties.
has ( string $property ) Returns if there is any value for the given property.
jsonSerialize ( ) : string Returns serialized properties.
properties ( ) : array Returns the entire set of properties.
set ( string $property, string $value ) Sets the value of the given property.
setDefault ( string $property, string $default ) Sets the value of a property if it is empty.
setDefaults ( array $properties ) Sets default values.
setProperties ( array $properties ) Sets the entire set of properties.

Method Details

__construct() public method

Constructs a Media from the given dataset.
public __construct ( array $properties = [] )
$properties array An array of media informations.

__get() public method

See also: get()
public __get ( $property )

__isset() public method

See also: has()
public __isset ( $property )

__set() public method

See also: set()
public __set ( $property, $value )

configure() public method

Merges the given properties with the current ones.
public configure ( array $properties )
$properties array Properties to merge.

filledProperties() public method

Returns the filled properties.
public filledProperties ( ) : array
return array Properties.

get() public method

Returns the value of the given property.
public get ( string $property, mixed $default = null ) : mixed
$property string Property name.
$default mixed Default value to be returned in case the property doesn't exists.
return mixed The property value, or $default.

getIterator() public method

Returns an iterator for the media properties.
public getIterator ( ) : ArrayIterator
return ArrayIterator Iterator.

has() public method

Returns if there is any value for the given property.
public has ( string $property )
$property string Property name.

jsonSerialize() public method

Returns serialized properties.
public jsonSerialize ( ) : string
return string JSON representation.

properties() public method

Returns the entire set of properties.
public properties ( ) : array
return array Properties.

set() public method

Sets the value of the given property.
public set ( string $property, string $value )
$property string Property name.
$value string New value.

setDefault() public method

Sets the value of a property if it is empty.
public setDefault ( string $property, string $default )
$property string Property name.
$default string Default value.

setDefaults() public method

Sets default values.
See also: setDefault()
public setDefaults ( array $properties )
$properties array Default properties.

setProperties() public method

Sets the entire set of properties.
public setProperties ( array $properties )
$properties array Properties to set.

Property Details

$_properties protected property

These default properties are gathered from the OEmbed and OpenGraph protocols, and provide all the basic informations needed to embed a media.
protected array $_properties
return array