Ergo\Http\RequestFactory::create PHP Method

create() public method

public create ( ) : Request
return Request
    public function create()
    {
        if (!isset($this->_instance)) {
            if ($this->_hasRequestMethod()) {
                $this->_instance = new Request($this->_getRequestMethod(), $this->_getUrl(), $this->_getHeaders(), $this->_getBody());
            } else {
                $this->_instance = new NullRequest(null, null);
            }
        }
        return $this->_instance;
    }

Usage Example

Example #1
0
 public function testRequestFactorySchemeHeader()
 {
     $server = array('SERVER_NAME' => 'example.com', 'HTTP_HOST' => 'example.com', 'SERVER_PORT' => '80', 'REQUEST_URI' => 'http://example.com/', 'REQUEST_METHOD' => 'GET', 'HTTP_X_FORWARDED_PROTO' => 'https');
     $factory = new Http\RequestFactory($server);
     $factory->setSchemeHeader('X-Forwarded-Proto');
     $request = $factory->create();
     $this->assertEquals($request->getRequestMethod(), 'GET');
     $this->assertEquals((string) $request->getUrl(), 'https://example.com/');
     $this->assertEquals($request->getUrl()->getScheme(), 'https');
 }
All Usage Examples Of Ergo\Http\RequestFactory::create