/** * Gets the request method, or checks it against $is * * <code> * // POST request example * $request->method() // returns 'POST' * $request->method('post') // returns true * $request->method('get') // returns false * </code> * * @param string $is The method to check the current request method against * @param boolean $allow_override Whether or not to allow HTTP method overriding via header or params * @access public * @return string | boolean */ public function method($is = null, $allow_override = true) { $method = $this->server->get('REQUEST_METHOD', 'GET'); // Override if ($allow_override && $method === 'POST') { // For legacy servers, override the HTTP method with the X-HTTP-Method-Override header or _method parameter if ($this->server->exists('X_HTTP_METHOD_OVERRIDE')) { $method = $this->server->get('X_HTTP_METHOD_OVERRIDE', $method); } else { $method = $this->param('_method', $method); } $method = strtoupper($method); } // We're doing a check if (null !== $is) { return strcasecmp($method, $is) === 0; } return $method; }
public function testHasPrefix() { $this->assertTrue(ServerDataCollection::hasPrefix('dog_wierd', 'dog')); $this->assertTrue(ServerDataCollection::hasPrefix('_dog_wierd', '_dog')); $this->assertFalse(ServerDataCollection::hasPrefix('_dog_wierd', 'dog')); }