src/Request/Request.php
public final static function fromPhpContext(PhpContext $phpContext)
    {
        if ($phpContext->isCliInvocation()) {
            $request = new CliRequest();
        } else {
            $contentType = (isset($_SERVER["CONTENT_TYPE"])) ? strtolower($_SERVER["CONTENT_TYPE"]) : "";

            // Special check for multipart, because the header could be multipart/form-data
            // followed by boundary
            $multipartType = "multipart/form-data";
            if (strpos($contentType, $multipartType) === 0) {
                $contentType = $multipartType;
            }

            // Firefox puts a charset on the end of the content type line
            $parts = explode(";", $contentType);
            $contentType = $parts[0];

            switch ($contentType) {
                case "application/octet-stream":
                case "image/jpeg":
                case "image/jpg":
                case "image/gif":
                case "image/png":
                    $request = new BinaryRequest();
                    break;
                case "application/json":
                    $request = new JsonRequest();
                    break;
                case "text/xml":
                case "application/xml":
                    $request = new XmlRequest();
                    break;
                case "multipart/form-data":
                    $request = new MultiPartFormDataRequest();
                    break;
                default:
                    $request = new WebRequest();
                    break;
            }
        }

        $request->phpContext = $phpContext;

        return $request;
    }
public final static function fromPhpContext(PhpContext $phpContext)
    {
        if ($phpContext->isCliInvocation()) {
            $request = new CliRequest();
        } else {
            $contentType = (isset($_SERVER["CONTENT_TYPE"])) ? strtolower($_SERVER["CONTENT_TYPE"]) : "";

            // Special check for multipart, because the header could be multipart/form-data
            // followed by boundary
            $multipartType = "multipart/form-data";
            if (strpos($contentType, $multipartType) === 0) {
                $contentType = $multipartType;
            }

            // Firefox puts a charset on the end of the content type line
            $parts = explode(";", $contentType);
            $contentType = $parts[0];

            switch ($contentType) {
                case "application/octet-stream":
                case "image/jpeg":
                case "image/jpg":
                case "image/gif":
                case "image/png":
                    $request = new BinaryRequest();
                    break;
                case "application/json":
                    $request = new JsonRequest();
                    break;
                case "text/xml":
                case "application/xml":
                    $request = new XmlRequest();
                    break;
                case "multipart/form-data":
                    $request = new MultiPartFormDataRequest();
                    break;
                default:
                    $request = new WebRequest();
                    break;
            }
        }

        $request->phpContext = $phpContext;

        return $request;
    }
public final static function fromPhpContext ( PhpContext $ phpContext ) { if ( $ phpContext -> isCliInvocation ( ) ) { $ request = new CliRequest ( ) ; } else { $ contentType = ( isset ( $ _SERVER [ "CONTENT_TYPE" ] ) ) ? strtolower ( $ _SERVER [ "CONTENT_TYPE" ] ) : "" ; // Special check for multipart, because the header could be multipart/form-data // followed by boundary $ multipartType = "multipart/form-data" ; if ( strpos ( $ contentType , $ multipartType ) === 0 ) { $ contentType = $ multipartType ; } // Firefox puts a charset on the end of the content type line $ parts = explode ( ";" , $ contentType ) ; $ contentType = $ parts [ 0 ] ; switch ( $ contentType ) { case "application/octet-stream" : case "image/jpeg" : case "image/jpg" : case "image/gif" : case "image/png" : $ request = new BinaryRequest ( ) ; break ; case "application/json" : $ request = new JsonRequest ( ) ; break ; case "text/xml" : case "application/xml" : $ request = new XmlRequest ( ) ; break ; case "multipart/form-data" : $ request = new MultiPartFormDataRequest ( ) ; break ; default : $ request = new WebRequest ( ) ; break ; } } $ request -> phpContext = $ phpContext ; return $ request ; }
Creates a request object from the PHP context

@return Request
Creates a request object from the PHP context