Skip to content

Commit 5410d41

Browse files
timedin-demickenordin
authored andcommitted
fix: use constants instead of raw strings
Signed-off-by: TimedIn <git@timedin.net>
1 parent a921f2a commit 5410d41

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

lib/Service/SubmissionService.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -872,21 +872,21 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
872872
// Text-based: evaluate regex/string conditions
873873
$text = $triggerAnswer[0] ?? '';
874874
foreach ($conditions as $condition) {
875-
$type = $condition['type'] ?? 'string_contains';
875+
$type = $condition['type'] ?? Constants::CONDITION_TYPE_STRING_CONTAINS;
876876
$value = $condition['value'] ?? '';
877877

878878
switch ($type) {
879-
case 'string_equals':
879+
case Constants::CONDITION_TYPE_STRING_EQUALS:
880880
if ($text === $value) {
881881
return true;
882882
}
883883
break;
884-
case 'string_contains':
884+
case Constants::CONDITION_TYPE_STRING_CONTAINS:
885885
if (str_contains($text, $value)) {
886886
return true;
887887
}
888888
break;
889-
case 'regex':
889+
case Constants::CONDITION_TYPE_REGEX:
890890
if ($this->safeRegexMatch($value, $text)) {
891891
return true;
892892
}
@@ -897,27 +897,27 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
897897
case Constants::ANSWER_TYPE_LINEARSCALE:
898898
$numValue = (float)($triggerAnswer[0] ?? 0);
899899
foreach ($conditions as $condition) {
900-
$type = $condition['type'] ?? 'value_equals';
901-
if ($type === 'value_equals') {
900+
$type = $condition['type'] ?? Constants::CONDITION_TYPE_VALUE_EQUALS;
901+
if ($type === Constants::CONDITION_TYPE_VALUE_EQUALS) {
902902
if ($numValue == (float)($condition['value'] ?? 0)) {
903903
return true;
904904
}
905-
} elseif ($type === 'value_not_equals') {
905+
} elseif ($type === Constants::CONDITION_TYPE_VALUE_NOT_EQUALS) {
906906
if ($numValue != (float)($condition['value'] ?? 0)) {
907907
return true;
908908
}
909-
} elseif ($type === 'value_range') {
909+
} elseif ($type === Constants::CONDITION_TYPE_VALUE_RANGE) {
910910
$min = $condition['min'] ?? -PHP_FLOAT_MAX;
911911
$max = $condition['max'] ?? PHP_FLOAT_MAX;
912912
if ($numValue >= $min && $numValue <= $max) {
913913
return true;
914914
}
915-
} elseif ($type === 'value_min') {
915+
} elseif ($type === Constants::CONDITION_TYPE_VALUE_MIN) {
916916
$min = $condition['min'] ?? -PHP_FLOAT_MAX;
917917
if ($numValue >= $min) {
918918
return true;
919919
}
920-
} elseif ($type === 'value_max') {
920+
} elseif ($type === Constants::CONDITION_TYPE_VALUE_MAX) {
921921
$max = $condition['max'] ?? PHP_FLOAT_MAX;
922922
if ($numValue <= $max) {
923923
return true;

0 commit comments

Comments
 (0)