protected function getResponseInstance($responseType, $responseWrapper = "")
    {
        // First, we check if the request type is a valid namespace: if so, we instantiate the given class
        $className = null;
        if (class_exists($responseType)) {
            $className = $responseType;
        } elseif (class_exists(AbstractActionRequest::RESPONSE_NAMESPACE . '\\' . $responseType)) {
            // If still not found, we add to the string the default namespace
            $className = AbstractActionRequest::RESPONSE_NAMESPACE . '\\' . $responseType;
        } elseif (class_exists(AbstractActionRequest::RESPONSE_NAMESPACE . '\\' . $responseType . AbstractActionRequest::RESPONSE_CLASSNAME_SUFFIX)) {
            // If still not found, we add to the string a default class name suffix and the default namespace
            $className = AbstractActionRequest::RESPONSE_NAMESPACE . '\\' . $responseType . AbstractActionRequest::RESPONSE_CLASSNAME_SUFFIX;
        } else {
            throw new UnsupportedResponseTypeException(
                sprintf('[%s] Unsupported response type: \'%s\'', $this->getApiName(), $responseType),
                $responseType
            );
        }

        // If not found, we launch an exception
        $responseObj = new $className();
        if (!$responseObj instanceof ActionResponseInterface) {
            throw new UnsupportedResponseTypeException($this->getNotValidRequestExMsg($responseObj), $responseType);
        }

        // Now checking if the given $responseWrapper parameter contains the namespace of a valid class name
        // that implements the interface \Msl\RemoteHost\Response\Wrapper\ResponseWrapperInterface
        $responseWrapperInterface = null;
        if (!is_null($responseWrapper) && !empty($responseWrapper)) {
            if (class_exists($responseWrapper)) {
                $responseWrapperInterface = new $responseWrapper;
                if ($responseWrapperInterface instanceof ResponseWrapperInterface) {
                    $responseObj->setResponseWrapper($responseWrapperInterface);
                }
            }
        }

        // If no response wrapper, we set the default one
        if (is_null($responseWrapperInterface)) {
            $responseWrapperInterface = new DefaultResponseWrapper();
        }

        // We set a response wrapper
        if ($responseWrapperInterface instanceof ResponseWrapperInterface) {
            $responseObj->setResponseWrapper($responseWrapperInterface);
        }

        // Return the ActionResponseInterface instance
        return $responseObj;
    }
protected function getResponseInstance($responseType, $responseWrapper = "")
    {
        // First, we check if the request type is a valid namespace: if so, we instantiate the given class
        $className = null;
        if (class_exists($responseType)) {
            $className = $responseType;
        } elseif (class_exists(AbstractActionRequest::RESPONSE_NAMESPACE . '\\' . $responseType)) {
            // If still not found, we add to the string the default namespace
            $className = AbstractActionRequest::RESPONSE_NAMESPACE . '\\' . $responseType;
        } elseif (class_exists(AbstractActionRequest::RESPONSE_NAMESPACE . '\\' . $responseType . AbstractActionRequest::RESPONSE_CLASSNAME_SUFFIX)) {
            // If still not found, we add to the string a default class name suffix and the default namespace
            $className = AbstractActionRequest::RESPONSE_NAMESPACE . '\\' . $responseType . AbstractActionRequest::RESPONSE_CLASSNAME_SUFFIX;
        } else {
            throw new UnsupportedResponseTypeException(
                sprintf('[%s] Unsupported response type: \'%s\'', $this->getApiName(), $responseType),
                $responseType
            );
        }

        // If not found, we launch an exception
        $responseObj = new $className();
        if (!$responseObj instanceof ActionResponseInterface) {
            throw new UnsupportedResponseTypeException($this->getNotValidRequestExMsg($responseObj), $responseType);
        }

        // Now checking if the given $responseWrapper parameter contains the namespace of a valid class name
        // that implements the interface \Msl\RemoteHost\Response\Wrapper\ResponseWrapperInterface
        $responseWrapperInterface = null;
        if (!is_null($responseWrapper) && !empty($responseWrapper)) {
            if (class_exists($responseWrapper)) {
                $responseWrapperInterface = new $responseWrapper;
                if ($responseWrapperInterface instanceof ResponseWrapperInterface) {
                    $responseObj->setResponseWrapper($responseWrapperInterface);
                }
            }
        }

        // If no response wrapper, we set the default one
        if (is_null($responseWrapperInterface)) {
            $responseWrapperInterface = new DefaultResponseWrapper();
        }

        // We set a response wrapper
        if ($responseWrapperInterface instanceof ResponseWrapperInterface) {
            $responseObj->setResponseWrapper($responseWrapperInterface);
        }

        // Return the ActionResponseInterface instance
        return $responseObj;
    }
protected function getResponseInstance ( $ responseType , $ responseWrapper = "" ) { // First, we check if the request type is a valid namespace: if so, we instantiate the given class $ className = null ; if ( class_exists ( $ responseType ) ) { $ className = $ responseType ; } elseif ( class_exists ( AbstractActionRequest :: RESPONSE_NAMESPACE . '\\' . $ responseType ) ) { // If still not found, we add to the string the default namespace $ className = AbstractActionRequest :: RESPONSE_NAMESPACE . '\\' . $ responseType ; } elseif ( class_exists ( AbstractActionRequest :: RESPONSE_NAMESPACE . '\\' . $ responseType . AbstractActionRequest :: RESPONSE_CLASSNAME_SUFFIX ) ) { // If still not found, we add to the string a default class name suffix and the default namespace $ className = AbstractActionRequest :: RESPONSE_NAMESPACE . '\\' . $ responseType . AbstractActionRequest :: RESPONSE_CLASSNAME_SUFFIX ; } else { throw new UnsupportedResponseTypeException ( sprintf ( '[%s] Unsupported response type: \'%s\'' , $ this -> getApiName ( ) , $ responseType ) , $ responseType ) ; } // If not found, we launch an exception $ responseObj = new $ className ( ) ; if ( ! $ responseObj instanceof ActionResponseInterface ) { throw new UnsupportedResponseTypeException ( $ this -> getNotValidRequestExMsg ( $ responseObj ) , $ responseType ) ; } // Now checking if the given $responseWrapper parameter contains the namespace of a valid class name // that implements the interface \Msl\RemoteHost\Response\Wrapper\ResponseWrapperInterface $ responseWrapperInterface = null ; if ( ! is_null ( $ responseWrapper ) && ! empty ( $ responseWrapper ) ) { if ( class_exists ( $ responseWrapper ) ) { $ responseWrapperInterface = new $ responseWrapper ; if ( $ responseWrapperInterface instanceof ResponseWrapperInterface ) { $ responseObj -> setResponseWrapper ( $ responseWrapperInterface ) ; } } } // If no response wrapper, we set the default one if ( is_null ( $ responseWrapperInterface ) ) { $ responseWrapperInterface = new DefaultResponseWrapper ( ) ; } // We set a response wrapper if ( $ responseWrapperInterface instanceof ResponseWrapperInterface ) { $ responseObj -> setResponseWrapper ( $ responseWrapperInterface ) ; } // Return the ActionResponseInterface instance return $ responseObj ; }
Returns a proper ActionResponseInterface.php instance for the given Response Type

@param string $responseType    string representation of a response type (could be a class name or a string identifier)
@param string $responseWrapper string representation of a response wrapper type (class name)

@return ActionResponseInterface

@throws \Msl\RemoteHost\Exception\UnsupportedResponseTypeException
Returns a proper ActionResponseInterface . php instance for the given Response Type