Zend\Diactoros\ServerRequest::getMethod PHP Method

getMethod() public method

This overrides the parent functionality to ensure the method is never empty; if no method is present, it returns 'GET'.
public getMethod ( ) : string
return string
    public function getMethod()
    {
        if (empty($this->method)) {
            return 'GET';
        }
        return $this->method;
    }

Usage Example

Example #1
0
 /**
  * @return mixed|null
  */
 public function getRoute()
 {
     $this->_routeMap->sortRoutes();
     foreach ($this->_routeMap as $route) {
         if ($this->_request->getMethod() !== $route->getRequestMethod()) {
             continue;
         }
         $route->replaceTokens();
         if (preg_match(sprintf("#^%s\$#i", $route->getPattern()), $this->_request->getUri()->getPath(), $matches)) {
             $this->_request = $this->_request->withAttribute('match', $route->getPattern());
             foreach ($matches as $key => $value) {
                 if (!is_int($key)) {
                     $this->_request = $this->_request->withAttribute($key, $value);
                 }
             }
             return $route;
         }
     }
     return null;
 }
All Usage Examples Of Zend\Diactoros\ServerRequest::getMethod