ManaPHP\Security\RateLimiter::limit PHP Метод

limit() публичный Метод

public limit ( string | array $controllerAction, integer $duration, integer $ip_times, integer $user_times = null ) : void
$controllerAction string | array
$duration integer
$ip_times integer
$user_times integer
Результат void
    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);
            }
        }
    }