src/RestClient.php
public function getResource($resource)
    {
        if (array_key_exists($resource, $this->cache)) {
            return $this->cache[$resource];
        }

        if (!array_key_exists($resource, $this->resources)) {
            throw new ResourceNotImplemented($resource);
        }

        $params = $this->resources[$resource];
        $instance = $params['instance'];

        if (is_null($instance)) {
            $class = $params['class'];

            $instance = new $class($this);
        }

        return $this->cache[$resource] = $instance;
    }
public function getResource($resource)
    {
        if (array_key_exists($resource, $this->cache)) {
            return $this->cache[$resource];
        }

        if (!array_key_exists($resource, $this->resources)) {
            throw new ResourceNotImplemented($resource);
        }

        $params = $this->resources[$resource];
        $instance = $params['instance'];

        if (is_null($instance)) {
            $class = $params['class'];

            $instance = new $class($this);
        }

        return $this->cache[$resource] = $instance;
    }
public function getResource ( $ resource ) { if ( array_key_exists ( $ resource , $ this -> cache ) ) { return $ this -> cache [ $ resource ] ; } if ( ! array_key_exists ( $ resource , $ this -> resources ) ) { throw new ResourceNotImplemented ( $ resource ) ; } $ params = $ this -> resources [ $ resource ] ; $ instance = $ params [ 'instance' ] ; if ( is_null ( $ instance ) ) { $ class = $ params [ 'class' ] ; $ instance = new $ class ( $ this ) ; } return $ this -> cache [ $ resource ] = $ instance ; }
Instantiates and returns the asked resource.

@param string $resource The resource name

@throws \Snorlax\Exception\ResourceNotImplemented If the resource is not available
@return \Snorlax\Resource The instantiated resource
Instantiates and returns the asked resource .