<?php

/**
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package fusionLib
 * @copyright Copyright (c) 2008 - 2013 fusionLib. All rights reserved.
 * @link http://fusionlib.com
 */

/**
 * flRequestThrottleException Class
 *
 * Exception thrown when a request is throttled.
 *
 * @package fusionLib
 */
class flRequestThrottleException extends flException {

	/**
	 * The request throttle obejct.
	 *
	 * @var flRequestThrottle
	 */
	private $throttle;

	/**
	 * Construct the exception.
	 *
	 * @param flRequestThrottle $throttle The request throttle object.
	 */
	function __construct($throttle) {
		parent::__construct(sprintf(__('The request limit of %1$d requests in %2$d seconds has been exceeded. Please wait %3$d seconds then try again.', 'fusionLib'), $throttle->getLimit(), $throttle->getTimeFrame(), $throttle->getWait()), 503);
		$this->throttle = $throttle;
	}

	/**
	 * Get the exception name.
	 *
	 * @return string The human readable exception name.
	 */
	function getName() {
		return __('Request Limit Reached', 'fusionLib');
	}

	/**
	 * Get the request throttling object.
	 *
	 * @return flRequestThrottle The request throttling object.
	 */
	function getThrottle() {
		return $this->throttle;
	}
}
