Exclude limits that are not currently applicable, because of a tighter scope.

@param $rules

@throws \Exception
171435
private function excludeIrrelevantRules(&$rules)
    {
        if (!empty($rules->rules)) {
            foreach ($rules->rules as $key => $limit) {
                if (
                    isset($limit->scope)
                    && CacheRepository::SCOPE_UTM_SOURCE === intval($limit->scope)
                    && strlen(trim($limit->value))
                    && trim($limit->value) !== $this->utmSource
                ) {
                    // This is a UTM Source limit, and we do not match it, so it is currently irrelevant to us.
                    unset($rules->rules[$key]);
                    continue;
                }
                if (
                    isset($limit->scope)
                    && CacheRepository::SCOPE_CATEGORY === intval($limit->scope)
                    && $limit->value
                    && $limit->value != $this->contactSource->getCategory()
                ) {
                    // This is a Category limit, and we do not match it, so it is currently irrelevant to us.
                    unset($rules->rules[$key]);
                    continue;
                }
            }
        }
    }
15980
public function add_rules( array $rules ) {
		foreach ( $rules as $name => $rule ) {
			$this->add_rule( $name, $rule );
		}

		return $this;
	}
927031
public function setPasswordStrengthRules($rules)
    {
        $this->_passwordStrengthRules = [];
        if (!is_array($rules)) {
            return;
        }
        foreach ($rules as $rule) {
            $this->_passwordStrengthRules[] = array_merge(['newPassword'], $rule);
        }
    }
778809
public function addRules($rules)
    {
        foreach ($rules as $rule) {
            $this->addrule($rule[0], $rule[1], $rule[2], isset($rule[3])?$rule[3]:null);
        }
    }
1193093
public function setLimit($limit)
    {
        if (is_array($limit)) {
            $spec = $limit;
            if (!isset($spec['name'])) {
                throw new \Exception("Cannot create Limit: Name missing from configuration.");
            }
            $name = $spec['name'];
            $limit = isset($spec['limit']) ? $spec['limit'] : null;
            $interval = isset($spec['interval']) ? $spec['interval'] : null;
            $actions = isset($spec['actions']) ? $spec['actions'] : array();
            
            $limit = new Limit($name, $limit, $interval);
            
            foreach ($actions as $action) {
                if (is_string($action)) {
                    $action = $this->getActionPlugins()->get($action);
                } elseif (is_array($action)) {
                    if (!isset($action['name'])) {
                        throw new \Exception('Cannot create Action: Name missing from configuration.');
                    }
                    $action = $this->getActionPlugins()->get($action['name'], $action);
                }
                
                if (!$action instanceof Action\ActionInterface) {
                    throw new \Exception("Action must be instance of Spork\Mvc\Listener\Limit\Action\ActionInterface");
                }
                
                $limit->addAction($action);
            }
        }
        
        if (!$limit instanceof Limit) {
            throw new \Exception("Limit must be instance of Spork\Mvc\Listener\Limit\Limit");
        }
        
        $this->limits[$limit->getName()] = $limit;
    }
1039919
public function limit($size) {
        LimitImpl::limit($this->context, $size);
        return new ExecRule($this->context);
    }
934039
protected function build_propositions( array $rules ) {
		$props = [];

		foreach ( $rules as $rule ) {
			if ( ! is_array( $rule ) || ! static::is_proposition( $rule ) ) {
				continue;
			}

			try {
				$props[] = $this->create_proposition( ... $rule );
			} catch ( \Exception $e ) {
				continue;
			}
		}

		return array_filter( $props );
	}
547500
public function filterRules($rules)
    {
        foreach ($this->_behaviors as $name => $foo) {
            if (($behavior = $this->getBehavior($name)) instanceof \nineinchnick\usr\components\FormModelBehavior) {
                $rules = $behavior->filterRules($rules);
            }
        }

        return $rules;
    }
986961
protected function setRules( array $rules )
	{
		foreach( $rules as $key => $rule ) {
			$rules[ $key ] = is_string( $rule ) ? explode( '|', $rule ) : $rule;
		}

		$this->rules = $rules;

		return $this;
	}
128202
protected function getLimitCondition( $limits = array() ){
		if( !is_array( $limits ) )
			return;
		$limit		= !isset( $limits[1] ) ? 0 : abs( $limits[1] );
		$offset		= !isset( $limits[0] ) ? 0 : abs( $limits[0] );
		if( $limit )
			return ' LIMIT '.$limit.' OFFSET '.$offset;
	}
1159886
public function offsetSet($field, $rules)
    {
        if (!$rules instanceof ValidationSet) {
            $set = new ValidationSet();
            foreach ((array)$rules as $name => $rule) {
                $set->add($name, $rule);
            }
        }
        $this->_fields[$field] = $rules;
    }
981917
public function setRules(array $rules)
    {
        $this->rules = [];
        foreach ($rules as $key => $value) {
            if (is_int($key)) {
                $routeRegex  = $value;
                $permissions = [];
            } else {
                $routeRegex  = $key;
                $permissions = (array) $value;
            }
            $this->rules[$routeRegex] = $permissions;
        }
    }
892149
public function setRules(array $rules)
    {
        $this->validators = [];
        foreach ($rules as $rule) {
            if (is_array($rule[0]) && is_string($rule[1])) {
                continue;
            }
            throw new InvalidArgumentException('Bad validation rule');
        }
        $this->rules = $rules;

        return $this;
    }
96051
public function mergeRules(array $rules)
    {
        $this->extendedRules = array_merge($this->extendedRules, $rules);
        $this->parsedRules = null;
        return $this;
    }
996036
public function setRules(array $rules)
    {
        foreach ($rules as $key => $values) {

            if ((is_array($values) === true && empty($values) === false) || is_callable($values)) {
                $this->rules[$key] = $values;
            } else {
                $this->rules[$key] = trim($values);
            }
        }

        return $this;
    }
1370012
public function excludeByRule(Closure $rule)
    {
        $result = $this->target;

        foreach ($result as $key => $value) {
            if ($rule($key, $value)) {
                unset($result[$key]);
            }
        }

        return $result;
    }
71851
private function fillParamsWithRequestRules($params, $rules)
    {
        foreach ($rules as $paramName => $rule) {
            if (isset($params[$paramName])) {
                continue;
            }

            $params[$paramName] = [
                'type'        => 'string',
                'name'        => $paramName,
                'description' => '',
                'template'    => $this->getParamTemplateByType('string'),
            ];
        }

        return $params;
    }