/**
* A concrete request class
*
- * @author Roland Haeder <webmaster@ship-simu.org>
+ * @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
* @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
+ * @link http://www.shipsimu.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* @return $httpInstance An instance of this class
*/
- public final static function createConsoleRequest () {
+ public static final function createConsoleRequest () {
// Create an instance
$httpInstance = new ConsoleRequest();
* Prepares the request data for usage
*
* @return void
- * @todo Needs to be implemented
*/
public function prepareRequestData () {
// Get the "request data" from the command-line argument list
} // END - if
// Is the first element "index.php" ?
- if ($args[0] == "index.php") {
+ if ($args[0] == 'index.php') {
// Then remove it
array_shift($args);
} // END - if
// Try to determine next parameters
foreach ($args as $arg) {
// Seperate arguemnt name from value
- $argArray = explode("=", $arg);
+ $argArray = explode('=', $arg);
// Is the second one set?
if (!isset($argArray[1])) {
// Add it likewise, but empty value
- $this->setRequestElement($argArray[0], "");
+ $this->setRequestElement($argArray[0], '');
} else {
// Set a name=value pair escaped and secured
$this->setRequestElement($argArray[0], escapeshellcmd($argArray[1]));
*
* @param $headerName Name of the header
* @return $headerValue Value of the header or 'null' if not found
+ * @throws UnsupportedOperationException This method should never be called
*/
- public function getHeader ($headerName) {
- $this->partialStub("Please implement this method.");
+ public function getHeaderElement ($headerName) {
+ // Console doesn't have any headers
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* @return $requestMethod Used request method
*/
public final function getRequestMethod () {
- return "LOCAL";
+ // @TODO Can't this be 'CONSOLE' ?
+ return 'LOCAL';
}
/**
*
* @param $cookieName Name of cookie we shall read
* @return $cookieValue Value of cookie or null if not found
+ * @throws UnsupportedOperationException This method should never be called
*/
public final function readCookie ($cookieName) {
- // @TODO There are no cookies on console
- return null;
+ // There are no cookies on console
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ }
+
+ /**
+ * Checks if the request method is GET.
+ *
+ * @return $isGet Whether the request method is GET
+ * @throws UnsupportedOperationException This method should never be called
+ */
+ public function isGetRequestMethod () {
+ // Not support method
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ }
+
+ /**
+ * Checks if the request method is HEAD.
+ *
+ * @return $isHead Whether the request method is HEAD
+ * @throws UnsupportedOperationException This method should never be called
+ */
+ public function isHeadRequestMethod () {
+ // Not support method
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
+ }
+
+ /**
+ * Checks if the request method is POST.
+ *
+ * @return $isPost Whether the request method is POST
+ * @throws UnsupportedOperationException This method should never be called
+ */
+ public function isPostRequestMethod () {
+ // Not support method
+ throw new UnsupportedOperationException(array($this, __FUNCTION__, $executorInstance), self::EXCEPTION_UNSPPORTED_OPERATION);
}
}