protected function prepareRules(array $rules)
    {
        // Prepared rules container
        $preparedRules = [];

        foreach ($rules as $key => $tests) {
            // Support arrays and pipes-splitted cases
            $tests = ! is_array($tests) ? explode('|', $tests) : $tests;

            // Prepared tests container
            $preparedTests = [];

            foreach ($tests as $test) {
                // If validation variable exists in
                // our variables array we'll replace it.
                $test = str_replace(array_keys($this->variables), array_values($this->variables), $test);

                // Sometimes we expect a validation variable
                // but it's not present in our variables array
                // so we need to replace it with "null"
                $test = preg_replace('|{:.*}|is', 'null', $test);

                // Add test to container
                $preparedTests[] = $test;
            }

            // Add rule to container
            $preparedRules[$key] = $preparedTests;
        }

        return $preparedRules;
    }
protected function prepareRules(array $rules)
    {
        // Prepared rules container
        $preparedRules = [];

        foreach ($rules as $key => $tests) {
            // Support arrays and pipes-splitted cases
            $tests = ! is_array($tests) ? explode('|', $tests) : $tests;

            // Prepared tests container
            $preparedTests = [];

            foreach ($tests as $test) {
                // If validation variable exists in
                // our variables array we'll replace it.
                $test = str_replace(array_keys($this->variables), array_values($this->variables), $test);

                // Sometimes we expect a validation variable
                // but it's not present in our variables array
                // so we need to replace it with "null"
                $test = preg_replace('|{:.*}|is', 'null', $test);

                // Add test to container
                $preparedTests[] = $test;
            }

            // Add rule to container
            $preparedRules[$key] = $preparedTests;
        }

        return $preparedRules;
    }
protected function prepareRules ( array $ rules ) { // Prepared rules container $ preparedRules = [ ] ; foreach ( $ rules as $ key => $ tests ) { // Support arrays and pipes-splitted cases $ tests = ! is_array ( $ tests ) ? explode ( '|' , $ tests ) : $ tests ; // Prepared tests container $ preparedTests = [ ] ; foreach ( $ tests as $ test ) { // If validation variable exists in // our variables array we'll replace it. $ test = str_replace ( array_keys ( $ this -> variables ) , array_values ( $ this -> variables ) , $ test ) ; // Sometimes we expect a validation variable // but it's not present in our variables array // so we need to replace it with "null" $ test = preg_replace ( '|{:.*}|is' , 'null' , $ test ) ; // Add test to container $ preparedTests [ ] = $ test ; } // Add rule to container $ preparedRules [ $ key ] = $ preparedTests ; } return $ preparedRules ; }
Prepare rules and each rule's tests.

@author Morten Rugaard <moru@nodes.dk>

@param  array $rules
@return array
Prepare rules and each rule s tests .