src/V1/ResourceCollection.php
private function parseResource($data)
    {
        if (! is_object($data)) {
            throw new ValidationException('Resources inside a collection MUST be objects, "' . gettype($data) . '" given.');
        }

        $object_vars = get_object_vars($data);

        // the 2 properties must be type and id
        // or the 3 properties must be type, id and meta
        if (count($object_vars) === 2 or (count($object_vars) === 3 and property_exists($data, 'meta'))) {
            $resource = $this->create('ResourceIdentifier', $data);
        } else {
            $resource = $this->create('ResourceItem', $data);
        }

        return $resource;
    }
private function parseResource($data)
    {
        if (! is_object($data)) {
            throw new ValidationException('Resources inside a collection MUST be objects, "' . gettype($data) . '" given.');
        }

        $object_vars = get_object_vars($data);

        // the 2 properties must be type and id
        // or the 3 properties must be type, id and meta
        if (count($object_vars) === 2 or (count($object_vars) === 3 and property_exists($data, 'meta'))) {
            $resource = $this->create('ResourceIdentifier', $data);
        } else {
            $resource = $this->create('ResourceItem', $data);
        }

        return $resource;
    }
private function parseResource ( $ data ) { if ( ! is_object ( $ data ) ) { throw new ValidationException ( 'Resources inside a collection MUST be objects, "' . gettype ( $ data ) . '" given.' ) ; } $ object_vars = get_object_vars ( $ data ) ; // the 2 properties must be type and id // or the 3 properties must be type, id and meta if ( count ( $ object_vars ) === 2 or ( count ( $ object_vars ) === 3 and property_exists ( $ data , 'meta' ) ) ) { $ resource = $ this -> create ( 'ResourceIdentifier' , $ data ) ; } else { $ resource = $ this -> create ( 'ResourceItem' , $ data ) ; } return $ resource ; }
Generate a new resource from an object

@param object $data The resource data

@return ElementInterface The resource
Generate a new resource from an object