protected function _objectToRDF($item) {
    $object = new stdClass();

    if(self::_isValue($item)) {
      $object->type = 'literal';
      $value = $item->{'@value'};
      $datatype = property_exists($item, '@type') ? $item->{'@type'} : null;

      // convert to XSD datatypes as appropriate
      if(is_bool($value)) {
        $object->value = ($value ? 'true' : 'false');
        $object->datatype = $datatype ? $datatype : self::XSD_BOOLEAN;
      } else if(is_double($value) || $datatype == self::XSD_DOUBLE) {
        // canonical double representation
        $object->value = preg_replace(
          '/(\d)0*E\+?/', '$1E', sprintf('%1.15E', $value));
        $object->datatype = $datatype ? $datatype : self::XSD_DOUBLE;
      } else if(is_integer($value)) {
        $object->value = strval($value);
        $object->datatype = $datatype ? $datatype : self::XSD_INTEGER;
      } else if(property_exists($item, '@language')) {
        $object->value = $value;
        $object->datatype = $datatype ? $datatype : self::RDF_LANGSTRING;
        $object->language = $item->{'@language'};
      } else {
        $object->value = $value;
        $object->datatype = $datatype ? $datatype : self::XSD_STRING;
      }
    } else {
      // convert string/node object to RDF
      $id = is_object($item) ? $item->{'@id'} : $item;
      $object->type = (strpos($id, '_:') === 0) ? 'blank node' : 'IRI';
      $object->value = $id;
    }

    // skip relative IRIs
    if($object->type === 'IRI' && !self::_isAbsoluteIri($object->value)) {
      return null;
    }

    return $object;
  }
protected function _objectToRDF($item) {
    $object = new stdClass();

    if(self::_isValue($item)) {
      $object->type = 'literal';
      $value = $item->{'@value'};
      $datatype = property_exists($item, '@type') ? $item->{'@type'} : null;

      // convert to XSD datatypes as appropriate
      if(is_bool($value)) {
        $object->value = ($value ? 'true' : 'false');
        $object->datatype = $datatype ? $datatype : self::XSD_BOOLEAN;
      } else if(is_double($value) || $datatype == self::XSD_DOUBLE) {
        // canonical double representation
        $object->value = preg_replace(
          '/(\d)0*E\+?/', '$1E', sprintf('%1.15E', $value));
        $object->datatype = $datatype ? $datatype : self::XSD_DOUBLE;
      } else if(is_integer($value)) {
        $object->value = strval($value);
        $object->datatype = $datatype ? $datatype : self::XSD_INTEGER;
      } else if(property_exists($item, '@language')) {
        $object->value = $value;
        $object->datatype = $datatype ? $datatype : self::RDF_LANGSTRING;
        $object->language = $item->{'@language'};
      } else {
        $object->value = $value;
        $object->datatype = $datatype ? $datatype : self::XSD_STRING;
      }
    } else {
      // convert string/node object to RDF
      $id = is_object($item) ? $item->{'@id'} : $item;
      $object->type = (strpos($id, '_:') === 0) ? 'blank node' : 'IRI';
      $object->value = $id;
    }

    // skip relative IRIs
    if($object->type === 'IRI' && !self::_isAbsoluteIri($object->value)) {
      return null;
    }

    return $object;
  }
protected function _objectToRDF ( $ item ) { $ object = new stdClass ( ) ; if ( self :: _isValue ( $ item ) ) { $ object -> type = 'literal' ; $ value = $ item -> { '@value' } ; $ datatype = property_exists ( $ item , '@type' ) ? $ item -> { '@type' } : null ; // convert to XSD datatypes as appropriate if ( is_bool ( $ value ) ) { $ object -> value = ( $ value ? 'true' : 'false' ) ; $ object -> datatype = $ datatype ? $ datatype : self :: XSD_BOOLEAN ; } else if ( is_double ( $ value ) || $ datatype == self :: XSD_DOUBLE ) { // canonical double representation $ object -> value = preg_replace ( '/(\d)0*E\+?/' , '$1E' , sprintf ( '%1.15E' , $ value ) ) ; $ object -> datatype = $ datatype ? $ datatype : self :: XSD_DOUBLE ; } else if ( is_integer ( $ value ) ) { $ object -> value = strval ( $ value ) ; $ object -> datatype = $ datatype ? $ datatype : self :: XSD_INTEGER ; } else if ( property_exists ( $ item , '@language' ) ) { $ object -> value = $ value ; $ object -> datatype = $ datatype ? $ datatype : self :: RDF_LANGSTRING ; $ object -> language = $ item -> { '@language' } ; } else { $ object -> value = $ value ; $ object -> datatype = $ datatype ? $ datatype : self :: XSD_STRING ; } } else { // convert string/node object to RDF $ id = is_object ( $ item ) ? $ item -> { '@id' } : $ item ; $ object -> type = ( strpos ( $ id , '_:' ) === 0 ) ? 'blank node' : 'IRI' ; $ object -> value = $ id ; } // skip relative IRIs if ( $ object -> type === 'IRI' && ! self :: _isAbsoluteIri ( $ object -> value ) ) { return null ; } return $ object ; }
Converts a JSON-LD value object to an RDF literal or a JSON-LD string or
node object to an RDF resource.

@param mixed $item the JSON-LD value or node object.

@return stdClass the RDF literal or RDF resource.
Converts a JSON - LD value object to an RDF literal or a JSON - LD string or node object to an RDF resource .