Exemplo n.º 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;
 }
Exemplo n.º 2
0
 /**
  * Check if an option exists
  * @param mixed $name
  * @return boolean
  */
 public function hasOption($name)
 {
     return $this->configuration->offsetExists($name);
 }