Created
June 27, 2012 05:06
-
-
Save dragoonis/3001615 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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