<?php

/**
 * Core
 *
 * @author Arkadiusz Rychlik <a.rychlik at eppe.com.pl>
 */
class Rtn_SimpleTable_Paginator_Params_Core {
	
	public $rowsPerPage = 10;
	public $setPageUrl;
	
	public function __construct($values=null) {
		if(is_array($values)){
			$this->setParams($values);
		}
	}
	
	public function setParams($values) {
		foreach($values as $k=>$v){
			$this->setParam($k, $v);
		}
		return $this;
	}
	
	public function setParam($param,$value) {
		if( property_exists($this, $param)){
			$this->$param = $value;
		}
		else{
			throw new Rtn_Exception(__('Unknown Paginator property :param',[':param'=>$param]));
		}
		
		return $this;
	}
	
	public function getRequiredParam($paramName) {
		if( property_exists($this,$paramName)){
			return $this->getParam($paramName);
		}
		else{
			throw new Rtn_Exception(__('Trying to get required paginator param :param',[':param'=>$paramName]));
		}
	}
	
	public function getParam($paramName=null,$default=null) {
		return property_exists($this, $paramName)
			? $this->$paramName
			: $default;
	}	
	
}
