/** * Factory method that instantiates a new UriAbstract object * * @static * @param string $type The type of Uri, can be GET or POST * @return CurrencyExchange\Uri\UriAbstract * @throws InvalidArgumentException */ public static function factory($type) { if (!HttpRequest::isHttpMethodSupported($type)) { throw new InvalidArgumentException('Unknown Uri type: ' . $type); } switch (strtoupper((string) $type)) { case HttpRequest::HTTP_GET: /** @var CurrencyExchange\Uri\UriGet */ $uri = new UriGet($type); break; case HttpRequest::HTTP_POST: /** @var CurrencyExchange\Uri\UriPost */ $uri = new UriPost($type); break; } return $uri; }
/** * Sets the type of this Uri, can be GET or POST * * @param string $type Uri type, can be GET or POST * @return CurrencyExchange\Uri\UriAbstract * @throws InvalidArgumentException */ public function setType($type) { if (!is_string($type)) { throw new InvalidArgumentException('Uri type must be a string, ' . gettype($type) . ' given.'); } if (!HttpRequest::isHttpMethodSupported($type)) { throw new InvalidArgumentException('Uri type must be GET or POST, ' . $type . ' given'); } $this->_type = strtoupper((string) $type); return $this; }
/** * @dataProvider providertestIsHttpMethodSupportedReturnsFalseIfMethodIsUnsupported */ public function testIsHttpMethodSupportedReturnsFalseIfMethodIsUnsupported($httpMethod) { $this->assertFalse(Request::isHttpMethodSupported($httpMethod)); }