EasyRdf API Documentation
Class

EasyRdf_Literal_Date

class EasyRdf_Literal_Date extends EasyRdf_Literal

Class that represents an RDF Literal of datatype xsd:date

Methods

static object create(mixed $value, string $lang = null, string $datatype = null)

Create a new literal object

from EasyRdf_Literal
static  setDatatypeMapping(string $datatype, string $class)

Register an RDF datatype with a PHP class name

from EasyRdf_Literal
static  deleteDatatypeMapping(string $datatype)

Remove the mapping between an RDF datatype and a PHP class name

from EasyRdf_Literal
static string getDatatypeForValue($value)

Get datatype URI for a PHP value.

from EasyRdf_Literal
object __construct(mixed $value = null, string $lang = null, string $datatype = null)

Constructor for creating a new date literal

string getValue()

Returns the date as a PHP DateTime object

string getDatatypeUri()

Returns the full datatype URI of the literal.

from EasyRdf_Literal
string getDatatype()

Returns the shortened datatype URI of the literal.

from EasyRdf_Literal
string getLang()

Returns the language of the literal.

from EasyRdf_Literal
array toRdfPhp()

Returns the properties of the literal as an associative array

from EasyRdf_Literal
string __toString()

Magic method to return the value of a literal as a string

from EasyRdf_Literal
string dumpValue(string $format = 'html', string $color = 'black')

Return pretty-print view of the literal

from EasyRdf_Literal
static object parse(string $value)

Parses a string using DateTime and creates a new literal

string format(string $format)

Returns date formatted according to given format

integer year()

A full integer representation of the year, 4 digits

integer month()

Integer representation of the month

integer day()

Integer representation of the day of the month

Details

in EasyRdf_Literal at line 79
static public object create(mixed $value, string $lang = null, string $datatype = null)

Create a new literal object

PHP values of type bool, int or float, will automatically be converted to the corresponding datatype and PHP sub-class.

If a registered datatype is given, then the registered subclass of EasyRdf_Literal will instantiated.

Note that literals are not required to have a language or datatype. Literals cannot have both a language and a datatype.

Parameters

mixed $value The value of the literal or an associative array
string $lang The natural language of the literal or null (e.g. 'en')
string $datatype The datatype of the literal or null (e.g. 'xsd:integer')

Return Value

object EasyRdfLiteral (or subclass of EasyRdfLiteral)

in EasyRdf_Literal at line 128
static public setDatatypeMapping(string $datatype, string $class)

Register an RDF datatype with a PHP class name

When parsing registered class will be used whenever the datatype is seen.

When serialising a registered class, the mapping will be used to set the datatype in the RDF.

Example: EasyRdfLiteral::registerDatatype('xsd:dateTime', 'MyDateTime_Class');

Parameters

string $datatype The RDF datatype (e.g. xsd:dateTime)
string $class The PHP class name (e.g. MyDateTimeClass)

in EasyRdf_Literal at line 151
static public deleteDatatypeMapping(string $datatype)

Remove the mapping between an RDF datatype and a PHP class name

Parameters

string $datatype The RDF datatype (e.g. xsd:dateTime)

in EasyRdf_Literal at line 176
static public string getDatatypeForValue($value)

Get datatype URI for a PHP value.

This static function is intended for internal use. Given a PHP value, it will return an XSD datatype URI for that value, for example: http://www.w3.org/2001/XMLSchema#integer

Parameters

$value

Return Value

string A URI for the datatype of $value.

at line 60
public object __construct(mixed $value = null, string $lang = null, string $datatype = null)

Constructor for creating a new date literal

If the value is a DateTime object, then it will be converted to the xsd:date format. If no value is given or is is null, then the current date is used.

Parameters

mixed $value The value of the literal
string $lang Should be null (literals with a datatype can't have a language)
string $datatype Optional datatype (default 'xsd:date')

Return Value

object EasyRdfLiteralDate

See also

DateTime

at line 95
public string getValue()

Returns the date as a PHP DateTime object

Return Value

string Value of this literal.

See also

DateTime::format

in EasyRdf_Literal at line 248
public string getDatatypeUri()

Returns the full datatype URI of the literal.

Return Value

string Datatype URI of this literal.

in EasyRdf_Literal at line 257
public string getDatatype()

Returns the shortened datatype URI of the literal.

Return Value

string Datatype of this literal (e.g. xsd:integer).

in EasyRdf_Literal at line 270
public string getLang()

Returns the language of the literal.

Return Value

string Language of this literal.

in EasyRdf_Literal at line 282
public array toRdfPhp()

Returns the properties of the literal as an associative array

For example: array('type' => 'literal', 'value' => 'string value')

Return Value

array The properties of the literal

in EasyRdf_Literal at line 304
public string __toString()

Magic method to return the value of a literal as a string

Return Value

string The value of the literal

in EasyRdf_Literal at line 315
public string dumpValue(string $format = 'html', string $color = 'black')

Return pretty-print view of the literal

Parameters

string $format Either 'html' or 'text'
string $color The colour of the text

Return Value

string

at line 84
static public object parse(string $value)

Parses a string using DateTime and creates a new literal

Example: $date = EasyRdfLiteralDate::parse('1 January 2011');

Parameters

string $value The date to parse

Return Value

object EasyRdfLiteralDate

See also

DateTime

at line 106
public string format(string $format)

Returns date formatted according to given format

Parameters

string $format

Return Value

string

See also

DateTime::format

at line 115
public integer year()

A full integer representation of the year, 4 digits

Return Value

integer

at line 124
public integer month()

Integer representation of the month

Return Value

integer

at line 133
public integer day()

Integer representation of the day of the month

Return Value

integer