| @@ -6,10 +6,12 @@ | ||
| 6 | 6 | use BitCode\BitForm\Core\Messages\SuccessMessageHandler; |
| 7 | 7 | use BitCode\BitForm\Core\Util\FieldValueHandler; |
| 8 | 8 | use BitCode\BitForm\Core\Util\SmartTags; |
| 9 | 9 | |
| 10 | -final class Helper { | |
| 11 | - public static function getFieldData($fields) { | |
| 10 | +final class Helper | |
| 11 | +{ | |
| 12 | + public static function getFieldData($fields) | |
| 13 | + { | |
| 12 | 14 | $fieldData = []; |
| 13 | 15 | |
| 14 | 16 | foreach ($fields as $fieldKey => $fieldDetail) { |
| 15 | 17 | $fieldData[$fieldKey] = [ |
| @@ -29,9 +31,10 @@ | ||
| 29 | 31 | } |
| 30 | 32 | return $fieldData; |
| 31 | 33 | } |
| 32 | 34 | |
| 33 | - public static function smartFldMargeFormFld($logics, $fieldData) { | |
| 35 | + public static function smartFldMargeFormFld($logics, $fieldData) | |
| 36 | + { | |
| 34 | 37 | $fieldKeys = SmartTags::smartTagFieldKeys(); |
| 35 | 38 | |
| 36 | 39 | foreach ($logics as $logic) { |
| 37 | 40 | $removeSpecialStr = ['${', '}', '()']; |
| @@ -51,9 +54,10 @@ | ||
| 51 | 54 | } |
| 52 | 55 | return $fieldData; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | - public static function replaceFieldWithValue($stringToReplaceField, $fieldValues, $evalMathExpr = true) { | |
| 58 | + public static function replaceFieldWithValue($stringToReplaceField, $fieldValues, $evalMathExpr = true) | |
| 59 | + { | |
| 56 | 60 | $stringToReplaceField = FieldValueHandler::replaceFieldWithValue($stringToReplaceField, $fieldValues); |
| 57 | 61 | if ($evalMathExpr) { |
| 58 | 62 | return self::evalMathExpression($stringToReplaceField); |
| 59 | 63 | } |
| @@ -59,9 +63,10 @@ | ||
| 59 | 63 | } |
| 60 | 64 | return $stringToReplaceField; |
| 61 | 65 | } |
| 62 | 66 | |
| 63 | - public static function setDefaultSubmitConfirmation($confirmationType, $fieldValue, $formId, $logID = 0) { | |
| 67 | + public static function setDefaultSubmitConfirmation($confirmationType, $fieldValue, $formId, $logID = 0) | |
| 68 | + { | |
| 64 | 69 | $messageId = 0; |
| 65 | 70 | $returnableData = null; |
| 66 | 71 | return [ |
| 67 | 72 | 'msg_id' => $messageId, |
| @@ -103,9 +108,10 @@ | ||
| 103 | 108 | 'confirmation' => $returnableData, |
| 104 | 109 | ]; |
| 105 | 110 | } |
| 106 | 111 | |
| 107 | - public static function calculte($firstOperand, $secondOperand, $operator) { | |
| 112 | + public static function calculte($firstOperand, $secondOperand, $operator) | |
| 113 | + { | |
| 108 | 114 | switch ($operator) { |
| 109 | 115 | case '+': |
| 110 | 116 | return $firstOperand + $secondOperand; |
| 111 | 117 | case '-': |
| @@ -118,13 +124,15 @@ | ||
| 118 | 124 | return $firstOperand ** $secondOperand; |
| 119 | 125 | } |
| 120 | 126 | } |
| 121 | 127 | |
| 122 | - public static function filterMailContentType() { | |
| 128 | + public static function filterMailContentType() | |
| 129 | + { | |
| 123 | 130 | return 'text/html'; |
| 124 | 131 | } |
| 125 | 132 | |
| 126 | - public static function evalMathExpression($stringWithFieldValue) { | |
| 133 | + public static function evalMathExpression($stringWithFieldValue) | |
| 134 | + { | |
| 127 | 135 | $mathExpr = $stringWithFieldValue; |
| 128 | 136 | if (empty($mathExpr)) { |
| 129 | 137 | return $stringWithFieldValue; |
| 130 | 138 | } |
| @@ -146,9 +154,9 @@ | ||
| 146 | 154 | if (!in_array(trim($value), $validOperator)) { |
| 147 | 155 | return $stringWithFieldValue; |
| 148 | 156 | } |
| 149 | 157 | } |
| 150 | - $mathExpr = str_replace(' ', null, $mathExpr); | |
| 158 | + $mathExpr = str_replace(' ', '', $mathExpr); | |
| 151 | 159 | $mathExpr = preg_replace('/\{|\[|\(/', '(', $mathExpr); |
| 152 | 160 | $mathExpr = preg_replace('/\}|\]/', ')', $mathExpr); |
| 153 | 161 | $calculated = self::infixToPostfixEvalute($mathExpr); |
| 154 | 162 | if (!is_null($calculated)) { |
| @@ -157,9 +165,10 @@ | ||
| 157 | 165 | |
| 158 | 166 | return (string) $stringWithFieldValue; |
| 159 | 167 | } |
| 160 | 168 | |
| 161 | - public static function infixToPostfixEvalute($expression) { | |
| 169 | + public static function infixToPostfixEvalute($expression) | |
| 170 | + { | |
| 162 | 171 | $operatorStack = []; |
| 163 | 172 | $outputQueue = []; |
| 164 | 173 | $numTemp = null; |
| 165 | 174 | for ($strIndex = 0; $strIndex < strlen($expression); $strIndex++) { |
| @@ -214,9 +223,10 @@ | ||
| 214 | 223 | } |
| 215 | 224 | return $resultStack; |
| 216 | 225 | } |
| 217 | 226 | |
| 218 | - public static function operatorPrecedence($operator) { | |
| 227 | + public static function operatorPrecedence($operator) | |
| 228 | + { | |
| 219 | 229 | $precedence = [ |
| 220 | 230 | '+' => 2, |
| 221 | 231 | '-' => 2, |
| 222 | 232 | '*' => 3, |
| @@ -226,9 +236,10 @@ | ||
| 226 | 236 | |
| 227 | 237 | return isset($precedence[$operator]) ? $precedence[$operator] : 0; |
| 228 | 238 | } |
| 229 | 239 | |
| 230 | - public static function calculate($firstOperand, $secondOperand, $operator) { | |
| 240 | + public static function calculate($firstOperand, $secondOperand, $operator) | |
| 241 | + { | |
| 231 | 242 | $calculated = [ |
| 232 | 243 | '+' => $firstOperand + $secondOperand, |
| 233 | 244 | '-' => $firstOperand - $secondOperand, |
| 234 | 245 | '*' => $firstOperand * $secondOperand, |