/** Check that a value parameter is valid, and convert it to an associative array if needed * @ignore */ protected function checkValueParam(&$value) { if (isset($value)) { if (is_object($value)) { if (!method_exists($value, 'toRdfPhp')) { // Convert to a literal object $value = Literal::create($value); } $value = $value->toRdfPhp(); } elseif (is_array($value)) { if (!isset($value['type'])) { throw new \InvalidArgumentException("\$value is missing a 'type' key"); } if (!isset($value['value'])) { throw new \InvalidArgumentException("\$value is missing a 'value' key"); } // Fix ordering and remove unknown keys $value = array('type' => strval($value['type']), 'value' => strval($value['value']), 'lang' => isset($value['lang']) ? strval($value['lang']) : null, 'datatype' => isset($value['datatype']) ? strval($value['datatype']) : null); } else { $value = array('type' => 'literal', 'value' => strval($value), 'datatype' => Literal::getDatatypeForValue($value)); } if (!in_array($value['type'], array('uri', 'bnode', 'literal'), true)) { throw new \InvalidArgumentException("\$value does not have a valid type (" . $value['type'] . ")"); } if (empty($value['datatype'])) { unset($value['datatype']); } if (empty($value['lang'])) { unset($value['lang']); } if (isset($value['lang']) and isset($value['datatype'])) { throw new \InvalidArgumentException("\$value cannot have both and language and a datatype"); } } }