Generate the output string of the more secure ini settings

@param array $rules Set of current rules
@return string INI string
355670
public function generateIniOutput($rules)
    {
        $ini = '';
        $config = array();

        foreach ($rules as $section => $ruleSet) {
            foreach ($ruleSet as $rule) {
                if (isset($rule->test)) {
                    if (is_object($rule->test)) {
                        if (!in_array($rule->test->operation, array('isset'))) {
                            $ini .= $rule->test->key.' = '.$rule->test->value."\n";
                        }
                    } else if (is_string($rule->test)) {
                        // no test object defined, this is a custom test
                        $testPath = '\\Psecio\\Iniscan\\Rule\\'.$rule->test;
                        if (class_exists($testPath)) {
                            $test = new $testPath($config, $section);
                            if (method_exists($test, '__toString')) {
                                $ini .= $test;
                            }
                        }
                    }
                }
            }
        }
        $ini .= "\n";
        return $ini;
    }
666752
private function setupRules($rules)
    {
        // prepares filter for requiredIf
        $rules = Utils\HelperRequiredIf::prepare($this, $rules);

        // prepares filter for sameWith.
        $rules = Utils\HelperSameWith::prepare($this, $rules);

        return $rules;
    }
220050
protected function bindPlaceholders(&$rules)
    {
        foreach ($rules as $name => &$rule) {
            if (isset($this->placeholder[$name])) {
                foreach ($this->placeholder[$name] as $bindName => $bind) {
                    $rule = preg_replace("/@$bindName/", $bind, $rule);
                }
            }
        }
        return $rules;
    }
1222362
public function getValidator(array $rules = []): Validator
    {
        $parser = new RulesParser($this->factories);

        return new Validator($rules, $parser, $this->translator);
    }
387273
public function setRules(array $rules): self
    {
        assert(empty($rules) === false);

        $this->rules = $rules;

        return $this;
    }
800614
protected function parse_array_rules( array $rules ) {
		$parse_rules = [];

		foreach ( $rules as $key => $value ) {
			if ( is_int( $key ) ) {
				$parse_rules[] = [ $this->normalize( $value ), [] ];
				continue;
			}

			$key = $this->normalize( $key );

			if ( ! is_array( $value ) ) {
				$value = [ $value ];
			}

			$parse_rules[] = [ $key, $this->wrap_parameters( $key, $value ) ];
		}

		return $parse_rules;
	}
132566
protected function parseRulesArray(array $rules)
    {
        $parsedRules = [];

        $rawRules = (new ValidationRuleParser($this->data))->explode($rules);

        foreach ($rawRules->rules as $attribute => $attributeRules) {
            foreach ($attributeRules as $attributeRule) {
                $parsedRule = $this->parseRuleString($attributeRule);
                if ($parsedRule) {
                    $parsedRules[$attribute][] = $parsedRule;
                }
            }
        }

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

        return $rules;
    }
126646
public static function parse_css_rules( array $rules ) {

		ob_start();

		foreach ( $rules as $rule => $properties ) {

			printf(
				"%s {\n",
				implode( ",\n", array_map( 'trim', explode( ',', $rule ) ) )
			);

			foreach ( $properties as $property => $value ) {

				printf( "\t%s: %s;\n", $property, $value );

			}

			echo "}\n";

		}

		return ob_get_clean();

	}
918082
private function sortRules(&$rules)
    {
        sort($rules);
        usort($rules, function ($a, $b) {
            return strlen($a) - strlen($b);
        });
    }
616671
public function storeWhiteList(array $rules)
    {
        $storedRules   = $this->repository->getEnabledWhitelist();
        $rulesToUpdate = [];
        $rulesToRemove = [];

        foreach ($storedRules as $storedRule) {
            $rule = $storedRule->getValue();
            $key  = array_search($rule, $rules, true);

            if ($key === false) {
                $rulesToRemove[] = $rule;
            } else if (in_array($rule, $rules, true)) {
                $rulesToUpdate[] = $rule;

                unset($rules[$key]);
            }
        }

        $rulesToStore = $rules;

        if (count($rulesToUpdate)) {
            Rule::query()->whereIn('value', $rulesToUpdate)->update(['expired_at' => null, 'status' => 1]);
        }

        if (count($rulesToStore)) {
            $date = Carbon::now();

            $rulesToStore = array_map(function($value) use($date) {
                return [
                    'value'      => $value,
                    'trusted'    => true,
                    'user_id'    => auth()->user()->getAuthIdentifier(),
                    'created_at' => $date->toDateTimeString(),
                    'status'     => 1,
                ];
            }, $rulesToStore);

            Rule::query()->insert($rulesToStore);
        }

        if (count($rulesToRemove)) {
            Rule::query()->whereIn('value', $rulesToRemove)->delete();
        }
    }
553897
protected function indexRules(array $rules)
    {        
        $this->indexedRules = array();
        
        foreach($rules as $rule){
            if(isset($this->indexedRules[$rule[self::LOOKUP_CHAR]])){
                $this->indexedRules[$rule[self::LOOKUP_CHAR]][] = $rule;
            } else {
                $this->indexedRules[$rule[self::LOOKUP_CHAR]] = array($rule);
            }
        }       
    }
388275
protected function extractCustomValidationShortName(array $rules)
    {
        $customRules = array_map(function ($rule) {
            $fullname = $this->getCustomRuleFullName($rule);

            if ($this->canHaveUsingCommand($fullname)) {
                $shortName = $this->getCustomRuleShortName($fullname);

                return $this->makeCustomRuleCall($shortName);
            }

            return $this->makeCustomRuleCall($fullname);

        }, $rules);

        return $customRules;
    }
263133
private function replaceBindings($rules)
	{

		// If we have no bindings we can just return the rules
		if (empty($this->bindings))
		{
			return $rules;
		}

		// Get any global bindings to merge into all bindings
		// Global bindings allow binding values to all the rules
		$globalBinding = $this->getGlobalBindings();

		foreach ($rules as $field => $rule)
		{
			// Field specific bindings
			$bindings = $this->getBindings($field);

			// Merge global bindings
			if ( ! empty($globalBinding))
			{
				$bindings = $bindings + $globalBinding;
			}

			foreach ($bindings as $key => $value)
			{
				$token = $this->tokenPrefix.$key.$this->tokenSuffix;

				if (is_array($rule))
				{

					// Handle array type rule sets
					$rule = array_map(function($v) use ($value, $token) {

						return str_replace($token, $value, $v);

					}, $rule);

				}
				else {

					// Handle piped style rule set
					$rule = str_replace($token, $value, $rule);

				}
			}

			// Set field rule
			$rules[$field] = $rule;
		}

		return $rules;
	}
1368639
public function & rules(array $rules){
      foreach ((array)$rules as $varname => $rule){
        $this->rules[$varname] = $rule;
      }
      $this->pattern         = $this->compilePatternAsRegex( $this->URLPattern, $this->rules );
      $this->matcher_pattern = $this->compilePatternAsRegex( $this->URLPattern, $this->rules, false );
      return $this;
    }
13576
private function array_to_css( array $rules )
    {
        $css = '';
        foreach( $rules as $rule => $value )
        {
            $css .= $rule.':'.$value.';';
        }
        return $css;
    }
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;
    }