/** * Sets another request method. * * @author David Pauli <*****@*****.**> * @since 0.0.0 * @since 0.1.0 Use HTTPRequestMethod enum. * @api * @param HTTPRequestMethod method The request method the REST client should use. * @return boolean True, if it works, false if not. */ public static function setRequestMethod($method) { if (!InputValidator::isRequestMethod($method)) { return false; } self::$HTTP_REQUEST_METHOD = $method; return true; }
/** * Sets another request method. * * @author David Pauli <*****@*****.**> * @param HTTPRequestMethod method The request method the REST client should use. * @return boolean True, if it works, false if not. * @since 0.0.0 * @since 0.1.0 Use HTTPRequestMethod enum. * @since 0.1.2 Throw warning with wrong parameters. * @since 0.1.2 Add error reporting. */ public static function setRequestMethod($method) { self::errorReset(); if (!InputValidator::isRequestMethod($method)) { Logger::warning("ep6\\RESTClient\nRequest method (" . $method . ") is not valid."); self::errorSet("RESTC-9"); return false; } self::$HTTP_REQUEST_METHOD = $method; return true; }
/** * @group utility */ function testIsRequestMethod() { $this->assertFalse(InputValidator::isRequestMethod("Some String")); $this->assertFalse(InputValidator::isRequestMethod(3)); $this->assertFalse(InputValidator::isRequestMethod(null)); $this->assertFalse(InputValidator::isRequestMethod(1.2)); $this->assertFalse(InputValidator::isRequestMethod("get")); $this->assertTrue(InputValidator::isRequestMethod("GET")); }