Beispiel #1
0
 /**
  * Build a new request from parameters
  * @param string $method
  * @param Url $url
  * @param array $headers
  * @return AbstractRequest
  * @throws UnknownProtocolException
  * @throws InvalidArgumentException
  */
 public function build($method, Url $url, array $headers)
 {
     if (($scheme = self::isAllowedScheme((string) $url->scheme())) === false) {
         throw new UnknownProtocolException(sprintf("You can't request a transfer on unsupported protocol '%s'!", $url->scheme()));
     }
     $scheme = ucfirst($scheme);
     $name = __NAMESPACE__ . '\\' . $scheme . '\\' . ucfirst(strtolower($method));
     if (!class_exists($name)) {
         throw new InvalidArgumentException('Method given is not a valid request: ' . $method);
     }
     $configurationClass = '\\Bee4\\Transport\\Configuration\\' . $scheme . 'Configuration';
     $request = new $name($url, $headers, new $configurationClass($this->configuration !== null ? $this->configuration->toArray() : []));
     return $request;
 }
Beispiel #2
0
 /**
  * @expectedException \Bee4\Transport\Exception\InvalidArgumentException
  */
 public function testSetInvalidScheme()
 {
     $url = new Url('http://www.bee4.fr');
     $url->scheme(null);
 }