public function limit($controllerAction, $duration, $ip_times, $user_times = null)
{
if ($controllerAction === null) {
$resource = $this->dispatcher->getControllerName() . ':' . $this->dispatcher->getActionName();
$this->limitAny($resource, $duration, $ip_times, $user_times);
} else {
if (is_array($controllerAction)) {
$resource = basename($controllerAction[0], 'Controller') . ':' . lcfirst(Text::camelize($controllerAction[1]));
} else {
$parts = explode(':', $controllerAction);
if (count($parts) !== 2) {
throw new RateLimiterException('`:controllerAction` controllerAction is invalid: the correct format is `controller:action`', ['controllerAction' => $controllerAction]);
}
$resource = Text::camelize($parts[0]) . ':' . lcfirst(Text::camelize($parts[1]));
}
if ($resource === $this->dispatcher->getControllerName() . ':' . $this->dispatcher->getActionName()) {
$this->limitAny($controllerAction, $duration, $ip_times, $user_times);
}
}
}