protected static function buildEntity($data)
    {
        $entities = static::getDefinedEntitiesArray();

        if (isset($data['entity']))
        {
            if (in_array($data['entity'], $entities))
            {
                $class = static::getEntityClass($data['entity']);
                $entity = new $class;
            }
            else
            {
                $entity = new static;
            }
        }
        else
        {
            $entity = new static;
        }

        $entity->fill($data);

        return $entity;
    }
protected static function buildEntity($data)
    {
        $entities = static::getDefinedEntitiesArray();

        if (isset($data['entity']))
        {
            if (in_array($data['entity'], $entities))
            {
                $class = static::getEntityClass($data['entity']);
                $entity = new $class;
            }
            else
            {
                $entity = new static;
            }
        }
        else
        {
            $entity = new static;
        }

        $entity->fill($data);

        return $entity;
    }
protected static function buildEntity ( $ data ) { $ entities = static :: getDefinedEntitiesArray ( ) ; if ( isset ( $ data [ 'entity' ] ) ) { if ( in_array ( $ data [ 'entity' ] , $ entities ) ) { $ class = static :: getEntityClass ( $ data [ 'entity' ] ) ; $ entity = new $ class ; } else { $ entity = new static ; } } else { $ entity = new static ; } $ entity -> fill ( $ data ) ; return $ entity ; }
Given the JSON response of an API call, wraps it to corresponding entity
class or a collection and returns the same.

@param array $data

@return Entity
Given the JSON response of an API call wraps it to corresponding entity class or a collection and returns the same .