Skip to content

Instantly share code, notes, and snippets.

@dragoonis
Created June 27, 2012 05:06
Show Gist options
  • Save dragoonis/3001615 to your computer and use it in GitHub Desktop.
Save dragoonis/3001615 to your computer and use it in GitHub Desktop.
<?php
/**
* The Routing Helper For The Controller
*
* @package Controller
* @author Paul Dragoonis <[email protected]>
* @license http://opensource.org/licenses/mit-license.php MIT
* @link http://www.ppi.io
*/
namespace PPI\Module\Routing;
class RoutingHelper {
/**
* The routing params
*
* @var array
*/
protected $_params = array();
public function __construct(array $params = array()) {
if(!empty($params)) {
$this->setParams($params);
}
}
/**
* Obtain a param's value
*
* @param string $param The param name
* @throws \InvalidArgumentException When the param does not exist
*/
public function getParam($param) {
if(!isset($this->_params[$param])) {
throw new \InvalidArgumentException('Unable to find routing param: ' . $param);
}
}
/**
* Set a routing param's value
*
* @param string $param
* @param string $value
*/
public function setParam($param, $value) {
$this->_params[$param] = $value;
}
/**
* Get all routing params
*
* @return array
*/
public function getParams() {
return $this->_params;
}
/**
* Set the routing params
*
* @param array $params
*/
public function setParams(array $params) {
$this->_params = $params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment