up() public static method

String to upper and trim
public static up ( $string ) : string
$string
return string
Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function request($url, $args, $method, Options $options)
 {
     $headers = $options->get('headers', array());
     $method = Filter::up($method);
     $args = 'GET' !== $method ? $args : array();
     $httpResult = \Requests::request($url, $headers, $args, $method, $this->_getClientOptions($options));
     if ($options->isExceptions() && $httpResult->status_code >= 400) {
         throw new Exception($httpResult->body, $httpResult->status_code);
     }
     return array($httpResult->status_code, $httpResult->headers->getAll(), $httpResult->body);
 }
Esempio n. 2
0
 /**
  * @param string            $url
  * @param string|array|null $args
  * @param string            $method
  * @param array             $options
  * @return Response
  * @throws Exception
  */
 public function request($url, $args = null, $method = Options::DEFAULT_METHOD, array $options = array())
 {
     $method = Filter::up($method);
     $url = 'GET' === $method ? Url::addArg((array) $args, $url) : $url;
     $options = new Options(array_merge($this->_options->getArrayCopy(), $options));
     $client = $this->_getClient($options);
     $response = new Response();
     try {
         list($code, $headers, $body) = $client->request($url, $args, $method, $options);
         $response->setCode($code);
         $response->setHeaders($headers);
         $response->setBody($body);
     } catch (\Exception $e) {
         if ($options->isExceptions()) {
             throw new Exception($e->getMessage(), $e->getCode(), $e);
         } else {
             $response->setCode($e->getCode());
             $response->setHeaders(array());
             $response->setBody($e->getMessage());
         }
     }
     return $response;
 }