Mini Shell
<?php
class Request {
// Request URI get/post params (param1=controller, param2=action, param3 (opt) = id)
// URI parameters are in the form "?controller=param1?action=param2&id=param3"
// These are rewritten by server rewrite engine from http://host/controller/action/id
// POST params from forms are merged in the same parameter array by router
private $parameters;
public function __construct($parameters) {
$this->parameters = $parameters;
}
// Test if param name is in request
public function existParameter($name) {
return (isset($this->parameters[$name]) && $this->parameters[$name] != "");
}
// Return param value from request
// Raise exception if param not found
public function getParameter($name) {
if ($this->existParameter($name)) {
return $this->parameters[$name];
}
else
return null;
//throw new ErrorException("Paramètre '$name' absent de la requête",0,E_USER_ERROR);
}
// Return all param values from request
public function getParameters() {
return $this->parameters;
}
// Unset particular param element
public function unsetParameter($name) {
if($this->existParameter($name)) unset($this->parameters[$name]);
}
}