public function getEndpoint($endpoint)
    {
        // Get Endpoint Class name
        $endpoint = studly_case($endpoint);

        if (!array_key_exists($endpoint, $this->endpoints)) {
            throw new InvalidEndpointException("Endpoint {$endpoint} does not exists");
        }

        $class = $this->endpoints[$endpoint];

        // Check if an instance has already been initiated
        if (isset($this->cachedEndpoints[$endpoint]) === false) {
            // check if class is an EndPoint
            $endpointClass = new \ReflectionClass($class);
            if (!$endpointClass->isSubclassOf('Atog\Api\Endpoint')) {
                throw new InvalidEndpointException("Class {$class} does not extend Atog\\Api\\Endpoint");
            }
            
            // check for model
            $model = new Model();
            if (array_key_exists('models', $this->config) && array_key_exists($endpoint, $this->config['models'])) {
                $modelClass = $this->config['models'][$endpoint];
                if (class_exists($modelClass)) {
                    $model = new $modelClass();
                }
            }
            $this->cachedEndpoints[$endpoint] = new $class($this, $model);
        }
        
        return $this->cachedEndpoints[$endpoint];
    }
public function getEndpoint($endpoint)
    {
        // Get Endpoint Class name
        $endpoint = studly_case($endpoint);

        if (!array_key_exists($endpoint, $this->endpoints)) {
            throw new InvalidEndpointException("Endpoint {$endpoint} does not exists");
        }

        $class = $this->endpoints[$endpoint];

        // Check if an instance has already been initiated
        if (isset($this->cachedEndpoints[$endpoint]) === false) {
            // check if class is an EndPoint
            $endpointClass = new \ReflectionClass($class);
            if (!$endpointClass->isSubclassOf('Atog\Api\Endpoint')) {
                throw new InvalidEndpointException("Class {$class} does not extend Atog\\Api\\Endpoint");
            }
            
            // check for model
            $model = new Model();
            if (array_key_exists('models', $this->config) && array_key_exists($endpoint, $this->config['models'])) {
                $modelClass = $this->config['models'][$endpoint];
                if (class_exists($modelClass)) {
                    $model = new $modelClass();
                }
            }
            $this->cachedEndpoints[$endpoint] = new $class($this, $model);
        }
        
        return $this->cachedEndpoints[$endpoint];
    }
public function getEndpoint ( $ endpoint ) { // Get Endpoint Class name $ endpoint = studly_case ( $ endpoint ) ; if ( ! array_key_exists ( $ endpoint , $ this -> endpoints ) ) { throw new InvalidEndpointException ( "Endpoint {$endpoint} does not exists" ) ; } $ class = $ this -> endpoints [ $ endpoint ] ; // Check if an instance has already been initiated if ( isset ( $ this -> cachedEndpoints [ $ endpoint ] ) === false ) { // check if class is an EndPoint $ endpointClass = new \ ReflectionClass ( $ class ) ; if ( ! $ endpointClass -> isSubclassOf ( 'Atog\Api\Endpoint' ) ) { throw new InvalidEndpointException ( "Class {$class} does not extend Atog\\Api\\Endpoint" ) ; } // check for model $ model = new Model ( ) ; if ( array_key_exists ( 'models' , $ this -> config ) && array_key_exists ( $ endpoint , $ this -> config [ 'models' ] ) ) { $ modelClass = $ this -> config [ 'models' ] [ $ endpoint ] ; if ( class_exists ( $ modelClass ) ) { $ model = new $ modelClass ( ) ; } } $ this -> cachedEndpoints [ $ endpoint ] = new $ class ( $ this , $ model ) ; } return $ this -> cachedEndpoints [ $ endpoint ] ; }
Get an API endpoint.
@param string $endpoint
@return \Atog\Api\Endpoint
@throws \Atog\Api\Exceptions\InvalidEndpointException
Get an API endpoint .