protected function normalizeRulesProperty($rules, $key)
    {
        if ($rules instanceof ValidationRuleDataInterface) {
            return $rules;
        }

        if (is_string($rules)) {
            // Convert Laravel's pipe-syntax to array
            $rules = explode('|', $rules);
        }

        if ( ! is_array($rules)) {
            $rules = (array) $rules;
        }

        // If the array is marked up in a special format, it can reflect the
        // contents of a validation rule dataobject directly.
        if ($key === static::VALIDATION_RULE_DATA_KEY) {
            return $this->makeValidationRuleDataFromSpecialArraySyntax($rules, '');
        }

        if (is_array(array_get($rules, static::VALIDATION_RULE_DATA_KEY))) {
            return $this->makeValidationRuleDataFromSpecialArraySyntax($rules[static::VALIDATION_RULE_DATA_KEY], $key);
        }

        // If the array is associative (and the key is non-numeric), included
        // it as a nested postfix for the field key, by including it in the data.
        return new ValidationRuleData($rules, is_numeric($key) ? null : $key);
    }
protected function normalizeRulesProperty($rules, $key)
    {
        if ($rules instanceof ValidationRuleDataInterface) {
            return $rules;
        }

        if (is_string($rules)) {
            // Convert Laravel's pipe-syntax to array
            $rules = explode('|', $rules);
        }

        if ( ! is_array($rules)) {
            $rules = (array) $rules;
        }

        // If the array is marked up in a special format, it can reflect the
        // contents of a validation rule dataobject directly.
        if ($key === static::VALIDATION_RULE_DATA_KEY) {
            return $this->makeValidationRuleDataFromSpecialArraySyntax($rules, '');
        }

        if (is_array(array_get($rules, static::VALIDATION_RULE_DATA_KEY))) {
            return $this->makeValidationRuleDataFromSpecialArraySyntax($rules[static::VALIDATION_RULE_DATA_KEY], $key);
        }

        // If the array is associative (and the key is non-numeric), included
        // it as a nested postfix for the field key, by including it in the data.
        return new ValidationRuleData($rules, is_numeric($key) ? null : $key);
    }
protected function normalizeRulesProperty ( $ rules , $ key ) { if ( $ rules instanceof ValidationRuleDataInterface ) { return $ rules ; } if ( is_string ( $ rules ) ) { // Convert Laravel's pipe-syntax to array $ rules = explode ( '|' , $ rules ) ; } if ( ! is_array ( $ rules ) ) { $ rules = ( array ) $ rules ; } // If the array is marked up in a special format, it can reflect the // contents of a validation rule dataobject directly. if ( $ key === static :: VALIDATION_RULE_DATA_KEY ) { return $ this -> makeValidationRuleDataFromSpecialArraySyntax ( $ rules , '' ) ; } if ( is_array ( array_get ( $ rules , static :: VALIDATION_RULE_DATA_KEY ) ) ) { return $ this -> makeValidationRuleDataFromSpecialArraySyntax ( $ rules [ static :: VALIDATION_RULE_DATA_KEY ] , $ key ) ; } // If the array is associative (and the key is non-numeric), included // it as a nested postfix for the field key, by including it in the data. return new ValidationRuleData ( $ rules , is_numeric ( $ key ) ? null : $ key ) ; }
Normalizes rules data for a single validation rule key.

@param mixed      $rules
@param int|string $key       The source array key
@return ValidationRuleDataInterface
Normalizes rules data for a single validation rule key .