': return $inputValue > $conditionValue; case '<': return $inputValue < $conditionValue; case '>=': return $inputValue >= $conditionValue; case '<=': return $inputValue <= $conditionValue; case 'startsWith': return Str::startsWith($inputValue, $conditionValue); case 'endsWith': return Str::endsWith($inputValue, $conditionValue); case 'contains': return Str::contains($inputValue, $conditionValue); case 'doNotContains': return !Str::contains($inputValue, $conditionValue); case 'length_equal': if (is_array($inputValue)) { return count($inputValue) == $conditionValue; } $inputValue = (string)$inputValue; return strlen($inputValue) == $conditionValue; case 'length_less_than': if (is_array($inputValue)) { return count($inputValue) < $conditionValue; } $inputValue = (string)$inputValue; return strlen($inputValue) < $conditionValue; case 'length_greater_than': if (is_array($inputValue)) { return count($inputValue) > $conditionValue; } $inputValue = (string)$inputValue; return strlen($inputValue) > $conditionValue; case 'test_regex': if (is_array($inputValue)) { $inputValue = implode(' ', $inputValue); } $pattern = '/' . $conditionValue . '/'; $result = @preg_match($pattern, $inputValue); if ($result === false) { // Invalid regex pattern, handle gracefully return false; } return (bool) $result; } } return false; } private static function processSmartCodesInValue($value, &$inputs, $form = null, $isArrayAcceptable = true) { if (strpos($value, '{') === false) { return $value; } if (preg_match('/^{inputs\.([^}]+)}$/', $value, $inputMatches)) { $fieldName = $inputMatches[1]; $fieldKey = str_replace(['[', ']'], ['.', ''], $fieldName); $resolvedValue = Arr::get($inputs, $fieldKey); if ($resolvedValue === null && $fieldKey !== $fieldName) { $resolvedValue = Arr::get($inputs, $fieldName); } // Return array if it's an array if (is_array($resolvedValue) && $isArrayAcceptable) { return $resolvedValue; } } try { $processedValue = preg_replace_callback('/{+(.*?)}/', function ($matches) use ($inputs, $form) { $smartCode = $matches[1]; if (false !== strpos($smartCode, 'inputs.')) { $fieldName = substr($smartCode, strlen('inputs.')); $fieldKey = str_replace(['[', ']'], ['.', ''], $fieldName); $value = Arr::get($inputs, $fieldKey, ''); if ($value === '' && $fieldKey !== $fieldName) { $value = Arr::get($inputs, $fieldName, ''); } if (is_array($value)) { $value = fluentImplodeRecursive(', ', $value); } return $value !== null && $value !== '' ? $value : ''; } // @todo Support general shortcodes in future // Always return the original value if we don't have a match return $matches[0]; }, $value); return $processedValue; } catch (\Exception $e) { return $value; } } }