src/RawPHP/RawRouter/Router.php
public function createController( $route, $params )
    {
        $control = NULL;
        $route   = ltrim( $route, '/' );
        $route   = rtrim( $route, '/' );

        $vars = explode( '/', $route );

        if ( 1 === count( $vars ) && '' == $vars[ 0 ] )
        {
            $control = $this->_buildControllerName( $this->defaultController . 'Controller' );

            // build action
            $aName = $this->_buildActionName( $control, $this->defaultAction );
        }
        else if ( 1 === count( $vars ) )
        {
            // controller /

            $control = $this->_buildControllerName( $vars[ 0 ] . 'Controller' );

            array_shift( $vars );

            // build action
            $aName = $this->_buildActionName( $control, $this->defaultAction );
        }
        else if ( 2 === count( $vars ) )
        {
            // controller / action
            $control = $this->_buildControllerName( $vars[ 0 ] . 'Controller' );

            array_shift( $vars );

            // build action
            $aName = $this->_buildActionName( $control, $vars[ 0 ] );
        }
        else if ( 2 < count( $vars ) )
        {
            // controller / action / params
            $control = $this->_buildControllerName( $vars[ 0 ] . 'Controller' );

            array_shift( $vars );

            // build action
            $aName = $this->_buildActionName( $control, $vars[ 0 ] );

            array_shift( $vars );
        }
        else
        {
            $control = $this->_buildControllerName( $this->defaultController . 'Controller' );

            $aName = $this->defaultAction . 'Action';
        }

        $action = new Action( $aName, $params );

        /** @var IController $controller */
        $controller = new $control( $this->config );
        $controller->setAction( $action );
        $controller->setDispatcher( $this->dispatcher );
        $controller->addDefaultListeners();

        return $controller;
    }
public function createController( $route, $params )
    {
        $control = NULL;
        $route   = ltrim( $route, '/' );
        $route   = rtrim( $route, '/' );

        $vars = explode( '/', $route );

        if ( 1 === count( $vars ) && '' == $vars[ 0 ] )
        {
            $control = $this->_buildControllerName( $this->defaultController . 'Controller' );

            // build action
            $aName = $this->_buildActionName( $control, $this->defaultAction );
        }
        else if ( 1 === count( $vars ) )
        {
            // controller /

            $control = $this->_buildControllerName( $vars[ 0 ] . 'Controller' );

            array_shift( $vars );

            // build action
            $aName = $this->_buildActionName( $control, $this->defaultAction );
        }
        else if ( 2 === count( $vars ) )
        {
            // controller / action
            $control = $this->_buildControllerName( $vars[ 0 ] . 'Controller' );

            array_shift( $vars );

            // build action
            $aName = $this->_buildActionName( $control, $vars[ 0 ] );
        }
        else if ( 2 < count( $vars ) )
        {
            // controller / action / params
            $control = $this->_buildControllerName( $vars[ 0 ] . 'Controller' );

            array_shift( $vars );

            // build action
            $aName = $this->_buildActionName( $control, $vars[ 0 ] );

            array_shift( $vars );
        }
        else
        {
            $control = $this->_buildControllerName( $this->defaultController . 'Controller' );

            $aName = $this->defaultAction . 'Action';
        }

        $action = new Action( $aName, $params );

        /** @var IController $controller */
        $controller = new $control( $this->config );
        $controller->setAction( $action );
        $controller->setDispatcher( $this->dispatcher );
        $controller->addDefaultListeners();

        return $controller;
    }
Creates a controller and its associated action.

@param string $route  the controller/action string
format [controllerName/actionName]
@param array  $params list of parameters

@return Controller instance of a controller