/** * @note The given URI must not contain serialization-specific * abbreviations or escapings, such as XML entities. * * @param string $uri The full URI * @param DataItem|null $dataItem * * @throws InvalidArgumentException */ public function __construct($uri, DataItem $dataItem = null) { if (!is_string($uri)) { throw new InvalidArgumentException('$uri needs to be a string'); } parent::__construct($dataItem); $this->uri = $uri; }
/** * @note The given lexical form should be the plain string for * representing the literal without datatype or language information. * It must not use any escaping or abbreviation mechanisms. * * @param string $lexicalForm lexical form * @param string $datatype Data type URI or empty for untyped literals * @param string $lang * @param DataItem|null $dataItem * * @throws InvalidArgumentException */ public function __construct($lexicalForm, $datatype = '', $lang = '', DataItem $dataItem = null) { if (!is_string($lexicalForm)) { throw new InvalidArgumentException('$lexicalForm needs to be a string'); } if (!is_string($datatype)) { throw new InvalidArgumentException('$datatype needs to be a string'); } // http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal if (!is_string($lang) || $lang !== '' && $datatype !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString') { throw new InvalidArgumentException('$lang needs to be a string and $datatype has to be of langString type'); } parent::__construct($dataItem); $this->lexicalForm = $lexicalForm; $this->datatype = $datatype; $this->lang = $lang; }
/** * @note The given lexical form should be the plain string for * representing the literal without datatype or language information. * It must not use any escaping or abbreviation mechanisms. * * @param string $lexicalForm lexical form * @param string $datatype Data type URI or empty for untyped literals * @param string $lang * @param DataItem|null $dataItem * * @throws InvalidArgumentException */ public function __construct($lexicalForm, $datatype = '', $lang = '', DataItem $dataItem = null) { if (!is_string($lexicalForm)) { throw new InvalidArgumentException('$lexicalForm needs to be a string'); } if (!is_string($datatype)) { throw new InvalidArgumentException('$datatype needs to be a string'); } if (!is_string($lang)) { throw new InvalidArgumentException('$lang needs to be a string and $datatype has to be of langString type'); } parent::__construct($dataItem); $this->lexicalForm = $lexicalForm; $this->datatype = $datatype; // 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString' // can also be used instead of the simple Foo@lang-tag convention // https://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-language-identifier // "...Plain literals have a lexical form and optionally a language tag as // defined by [RFC-3066], normalized to lowercase..." // https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal // "...Lexical representations of language tags may be converted to // lower case. The value space of language tags is always in lower case..." $this->lang = strtolower($lang); }