Convert a data element to a resource object.

@param $data

@return mixed
186494
protected function convertToResource($data)
    {
        return ResourceSharingRequest::make($this->client, $data->request_id)
            ->init($data);
    }
233067
public function toArray($data)
    {
        $doc = new DomDocument('1.0', 'UTF-8');
        $doc->loadXML($data);
        $element = $doc->documentElement;

        return $this->convertDOMElementToArray($element);
    }
1036918
public function convert($data)
    {
        foreach ($this->chain as $converter) {
            $result = $converter->convert($data);
            if ($result !== false) {
                return $result;
            }
        }
        
        return false;
    }
1240933
public static function deserializeObject(array $data)
    {
        /** @var ResourceType $result */
        $result = self::deserializeCommonAttributes($data);
        $result->name = $data['name'];
        $result->description = $data['description'];
        $result->endpoint = $data['endpoint'];
        $result->schema = $data['schema'];
        if (isset($data['schemaExtensions'])) {
            $result->schemaExtensions = [];
            foreach ($data['schemaExtensions'] as $schemaExtension) {
                $result->schemaExtensions[$schemaExtension['schema']] = $schemaExtension['required'];
            }
        }

        return $result;
    }
793177
protected function extractData(array $data)
    {
        $converted = array();

        foreach ($data as $value) {

            if ($value instanceof Result) {

                $converted[$value->getId()] = $value->getData();
            }
        }

        return $converted;
    }
1336973
public function data($data=''){
        if('' === $data && !empty($this->data)) {
            return $this->data;
        }
        if(is_object($data)){
            $data   =   get_object_vars($data);
        }elseif(is_string($data)){
            parse_str($data,$data);
        }elseif(!is_array($data)){
            E(L('_DATA_TYPE_INVALID_'));
        }
        $this->data = $data;
        return $this;
    }
170925
protected function convertToResource($data)
    {
        return Item::make($this->client, $this->bib, $this->holding, $data->item_data->pid)
            ->init($data);
    }
356049
public function reverseTransform($data)
    {
        if (self::MODE_TO_INTERNAL === (self::MODE_TO_INTERNAL & $this->mode)) {
            return $this->map($data, UrlMapperInterface::MODE_PUBLIC_TO_INTERNAL);
        } else {
            return $data;
        }
    }
930410
public function unserialize($data)
    {
        $object = @unserialize($data);
        if($object === false) {
            throw new SerializerException("Unable to unserialize data: " . $data);
        }

        return $object;
    }
1023740
protected function toArray($data)
	{
	    if (is_array($data)) {
	        return $data;
	    }
	    
	    if (is_object($data)) {
	        if (method_exists($data, 'toArray')) {
	            return $data->toArray();
	        }
	        if ($data instanceof \Traversable) {
	            return iterator_to_array($data);
	        }
	    }
	    
	    return (array) $data;
	}
766824
protected function jsonEncode($data)
    {
        $return = json_encode($data);

        if ($return === false) {
            throw new ConverterException(
                sprintf(
                    "Could not convert %s data to JSON. Driver returned '%s'.",
                    gettype($data),
                    json_last_error()
                )
            );
        }

        return $return;
    }
523169
public function deserialize($data, ResourceType $resourceType = null)
    {
        if (empty($resourceType)) {
            $resourceType = new ResourceType();
        }
        $resourceType->setName($data['name']);

        return $resourceType;
    }
519597
public function decode($data)
    {
        $parser = new Parser();
        $this->arrayData = (array) $parser->parse($data);
        return $this->arrayData;
    }
592675
protected function transform($data)
    {

        // FILE level items
        $items = [
            'uses'          => [ ],
            'source'        => gzuncompress(base64_decode($data[ 'source' ])),
            'parse_markers' => $data[ 'parse_markers' ],
        ];

        if ( $data->has('namespace-alias') ) {
            $items[ 'uses' ] = is_string($data[ 'namespace-alias' ]) ? [ $data[ 'namespace-alias' ] ] : $data[ 'namespace-alias' ];
        }
        $items = array_merge($items, [
            'path'                  => $data[ '@attributes.path' ],
            'hash'                  => $data[ '@attributes.hash' ],
            'file_description'      => $this->createDescription($data[ 'docblock.description' ]),
            'file_long-description' => $this->createDescription($data[ 'docblock.long-description' ]),

        ]);


        $items[ 'type' ] = null;
        if ( $data->has('class') ) {
            $items[ 'type' ] = 'class';
        } elseif ( $data->has('trait') ) {
            $items[ 'type' ] = 'trait';
        } elseif ( $data->has('interface') ) {
            $items[ 'type' ] = 'interface';
        }

        $this->items = $items;
        if ( $items[ 'type' ] !== null ) {
            $items[ 'entity' ] = new Entity($data[ $items[ 'type' ] ], $this->factory, $this);
        }


        return $items;
    }
640717
private function parseData($data)
    {
        if ($data === null) {
            return $this->create('ResourceNull', $data);
        }

        if (is_array($data)) {
            return $this->create('ResourceCollection', $data);
        }

        if (! is_object($data)) {
            throw new ValidationException('Data value has to be null or an object, "' . gettype($data) . '" given.');
        }

        $object_keys = array_keys(get_object_vars($data));
        sort($object_keys);

        // the properties must be type and id or
        // the 3 properties must be type, id and meta
        if ($object_keys === ['id', 'type'] or $object_keys === ['id', 'meta', 'type']) {
            $resource = $this->create('ResourceIdentifier', $data);
        } else {
            // #Workaround: preset `data` with null, so ResourceItem can distinguish his parent between Document and ResourceCollection
            $this->set('data', null);
            $resource = $this->create('ResourceItem', $data);
        }

        return $resource;
    }
858203
private function convertSerializedToObjects($data)
    {
        $data = @unserialize($data);

        // If it is an object then
        // we can just return it...
        if (is_object($data))
        {
            return $data;
        }

        // It could be a associative array so use
        // JSON to encode it and then decode it properly...
        if (is_array($data) and $json = $this->convertToJson($data))
        {
            return $this->convertJsonToObjects($json);
        }

        return null;
    }
589374
public function create($data)
    {
        $descriptor = new UsesDescriptor($data->getName());
        $descriptor->setDescription($data->getDescription());
        $reference = $data->getReference();

        $descriptor->setReference($reference);

        return $descriptor;
    }