Boolean
class Boolean extends Literal
Class that represents an RDF Literal of datatype xsd:boolean
Properties
protected | $value | from Literal | |
protected | $lang | from Literal | |
protected | $datatype | from Literal |
Methods
Create a new literal object
Register an RDF datatype with a PHP class name
Remove the mapping between an RDF datatype and a PHP class name
Constructor for creating a new boolean literal
Return the value of the literal cast to a PHP bool
Return pretty-print view of the literal
Return true if the value of the literal is 'true' or '1'
Return true if the value of the literal is 'false' or '0'
Details
in
Literal at line 81
static Literal
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.
in
Literal at line 132
static
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: EasyRdf\Literal::registerDatatype('xsd:dateTime', 'My_DateTime_Class');
in
Literal at line 157
static
deleteDatatypeMapping(string $datatype)
Remove the mapping between an RDF datatype and a PHP class name
in
Literal at line 184
static string
getDatatypeForValue(mixed $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
at line 58
Literal
__construct(string $value, string $lang = null, string $datatype = null)
Constructor for creating a new boolean literal
If the value is not a string, then it will be converted to 'true' or 'false'.
at line 72
string
getValue()
Return the value of the literal cast to a PHP bool
If the value is 'true' or '1' return true, otherwise returns false.
in
Literal at line 257
string
getDatatypeUri()
Returns the full datatype URI of the literal.
in
Literal at line 266
string
getDatatype()
Returns the shortened datatype URI of the literal.
in
Literal at line 279
string
getLang()
Returns the language of the literal.
in
Literal at line 291
array
toRdfPhp()
Returns the properties of the literal as an associative array
For example: array('type' => 'literal', 'value' => 'string value')
in
Literal at line 313
string
__toString()
Magic method to return the value of a literal as a string
in
Literal at line 325
string
dumpValue(string $format = 'html', string $color = 'black')
Return pretty-print view of the literal
at line 81
bool
isTrue()
Return true if the value of the literal is 'true' or '1'
at line 90
bool
isFalse()
Return true if the value of the literal is 'false' or '0'