/**
  * {@inheritdoc}
  */
 public function create()
 {
     if (null === $this->request) {
         return null;
     }
     $http = new Http($this->request->getUriForPath($this->request->getPathInfo()), $this->request->getMethod());
     $queryString = $this->request->getQueryString();
     if (strlen($queryString) > 0) {
         $http->setQueryString($queryString);
     }
     $http->setData($this->request->request->all());
     $http->setCookies($this->request->cookies->all());
     $http->setHeaders(array_map(function (array $values) {
         return count($values) === 1 ? reset($values) : $values;
     }, $this->request->headers->all()));
     $http->setEnv($this->request->server->all());
     return $http;
 }
 /**
  * {@inheritdoc}
  */
 public function create()
 {
     if (php_sapi_name() === 'cli') {
         return null;
     }
     $env = $headers = array();
     foreach ($_SERVER as $key => $value) {
         if (0 === strpos($key, 'HTTP_')) {
             if (in_array($key, array('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'))) {
                 continue;
             }
             $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))))] = $value;
         } elseif (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
             $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', $key))))] = $value;
         } else {
             $env[$key] = $value;
         }
     }
     $http = new Http($this->getCurrentUrl(), $_REQUEST['REQUEST_METHOD']);
     if (isset($_REQUEST['QUERY_STRING'])) {
         $http->setQueryString($_REQUEST['QUERY_STRING']);
     }
     if (!empty($_POST)) {
         $http->setData($_POST);
     }
     if (!empty($_COOKIE)) {
         $http->setCookies($_COOKIE);
     }
     if (!empty($headers)) {
         $http->setHeaders($headers);
     }
     if (!empty($env)) {
         $http->setEnv($env);
     }
     return $http;
 }