style: Laravel Pint 코드 포맷팅 적용
- PSR-12 스타일 가이드 준수 - 302개 파일 스타일 이슈 자동 수정 - 코드 로직 변경 없음 (포맷팅만)
This commit is contained in:
@@ -8,8 +8,9 @@ class FormulaParser
|
||||
{
|
||||
/**
|
||||
* 계산식 실행
|
||||
* @param string $formula 계산식 표현식
|
||||
* @param array $variables 변수 값들
|
||||
*
|
||||
* @param string $formula 계산식 표현식
|
||||
* @param array $variables 변수 값들
|
||||
* @return array|float 계산 결과
|
||||
*/
|
||||
public function execute(string $formula, array $variables): array|float
|
||||
@@ -28,7 +29,7 @@ public function execute(string $formula, array $variables): array|float
|
||||
Log::error('계산식 실행 실패', [
|
||||
'formula' => $formula,
|
||||
'variables' => $variables,
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
throw new \RuntimeException("계산식 실행 실패: {$e->getMessage()}");
|
||||
@@ -67,7 +68,7 @@ protected function executePreDefinedFunction(string $formula, array $variables):
|
||||
if ($formula === 'kyungdong_screen_size') {
|
||||
return [
|
||||
'W1' => ($variables['W0'] ?? 0) + 160,
|
||||
'H1' => ($variables['H0'] ?? 0) + 350
|
||||
'H1' => ($variables['H0'] ?? 0) + 350,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ protected function executePreDefinedFunction(string $formula, array $variables):
|
||||
if ($formula === 'kyungdong_steel_size') {
|
||||
return [
|
||||
'W1' => ($variables['W0'] ?? 0) + 110,
|
||||
'H1' => ($variables['H0'] ?? 0) + 350
|
||||
'H1' => ($variables['H0'] ?? 0) + 350,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -88,17 +89,26 @@ protected function executePreDefinedFunction(string $formula, array $variables):
|
||||
|
||||
return [
|
||||
'area' => $area,
|
||||
'weight' => ($area * 2) + ($W0 / 1000 * 14.17)
|
||||
'weight' => ($area * 2) + ($W0 / 1000 * 14.17),
|
||||
];
|
||||
}
|
||||
|
||||
// 브라켓 수량 계산
|
||||
if ($formula === 'bracket_quantity') {
|
||||
$W1 = $variables['W1'] ?? 0;
|
||||
if ($W1 <= 3000) return ['result' => 2];
|
||||
if ($W1 <= 6000) return ['result' => 3];
|
||||
if ($W1 <= 9000) return ['result' => 4];
|
||||
if ($W1 <= 12000) return ['result' => 5];
|
||||
if ($W1 <= 3000) {
|
||||
return ['result' => 2];
|
||||
}
|
||||
if ($W1 <= 6000) {
|
||||
return ['result' => 3];
|
||||
}
|
||||
if ($W1 <= 9000) {
|
||||
return ['result' => 4];
|
||||
}
|
||||
if ($W1 <= 12000) {
|
||||
return ['result' => 5];
|
||||
}
|
||||
|
||||
return ['result' => 5]; // 최대값
|
||||
}
|
||||
|
||||
@@ -112,10 +122,19 @@ protected function executePreDefinedFunction(string $formula, array $variables):
|
||||
$W1 = $variables['W1'] ?? 0;
|
||||
$qty = $variables['qty'] ?? 1;
|
||||
|
||||
if ($W1 <= 3000) return ['result' => 1 * $qty];
|
||||
if ($W1 <= 6000) return ['result' => 2 * $qty];
|
||||
if ($W1 <= 9000) return ['result' => 3 * $qty];
|
||||
if ($W1 <= 12000) return ['result' => 4 * $qty];
|
||||
if ($W1 <= 3000) {
|
||||
return ['result' => 1 * $qty];
|
||||
}
|
||||
if ($W1 <= 6000) {
|
||||
return ['result' => 2 * $qty];
|
||||
}
|
||||
if ($W1 <= 9000) {
|
||||
return ['result' => 3 * $qty];
|
||||
}
|
||||
if ($W1 <= 12000) {
|
||||
return ['result' => 4 * $qty];
|
||||
}
|
||||
|
||||
return ['result' => 4 * $qty];
|
||||
}
|
||||
|
||||
@@ -123,8 +142,13 @@ protected function executePreDefinedFunction(string $formula, array $variables):
|
||||
if ($formula === 'shaft_size_determination') {
|
||||
$W1 = $variables['W1'] ?? 0;
|
||||
|
||||
if ($W1 <= 6000) return ['result' => 4]; // 4인치
|
||||
if ($W1 <= 8200) return ['result' => 5]; // 5인치
|
||||
if ($W1 <= 6000) {
|
||||
return ['result' => 4];
|
||||
} // 4인치
|
||||
if ($W1 <= 8200) {
|
||||
return ['result' => 5];
|
||||
} // 5인치
|
||||
|
||||
return ['result' => 0]; // 미정의
|
||||
}
|
||||
|
||||
@@ -135,23 +159,53 @@ protected function executePreDefinedFunction(string $formula, array $variables):
|
||||
|
||||
// 샤프트별 중량 매트릭스
|
||||
if ($shaftSize == 4) {
|
||||
if ($weight <= 150) return ['result' => '150K'];
|
||||
if ($weight <= 300) return ['result' => '300K'];
|
||||
if ($weight <= 400) return ['result' => '400K'];
|
||||
if ($weight <= 150) {
|
||||
return ['result' => '150K'];
|
||||
}
|
||||
if ($weight <= 300) {
|
||||
return ['result' => '300K'];
|
||||
}
|
||||
if ($weight <= 400) {
|
||||
return ['result' => '400K'];
|
||||
}
|
||||
} elseif ($shaftSize == 5) {
|
||||
if ($weight <= 123) return ['result' => '150K'];
|
||||
if ($weight <= 246) return ['result' => '300K'];
|
||||
if ($weight <= 327) return ['result' => '400K'];
|
||||
if ($weight <= 500) return ['result' => '500K'];
|
||||
if ($weight <= 600) return ['result' => '600K'];
|
||||
if ($weight <= 123) {
|
||||
return ['result' => '150K'];
|
||||
}
|
||||
if ($weight <= 246) {
|
||||
return ['result' => '300K'];
|
||||
}
|
||||
if ($weight <= 327) {
|
||||
return ['result' => '400K'];
|
||||
}
|
||||
if ($weight <= 500) {
|
||||
return ['result' => '500K'];
|
||||
}
|
||||
if ($weight <= 600) {
|
||||
return ['result' => '600K'];
|
||||
}
|
||||
} elseif ($shaftSize == 6) {
|
||||
if ($weight <= 104) return ['result' => '150K'];
|
||||
if ($weight <= 208) return ['result' => '300K'];
|
||||
if ($weight <= 300) return ['result' => '400K'];
|
||||
if ($weight <= 424) return ['result' => '500K'];
|
||||
if ($weight <= 508) return ['result' => '600K'];
|
||||
if ($weight <= 800) return ['result' => '800K'];
|
||||
if ($weight <= 1000) return ['result' => '1000K'];
|
||||
if ($weight <= 104) {
|
||||
return ['result' => '150K'];
|
||||
}
|
||||
if ($weight <= 208) {
|
||||
return ['result' => '300K'];
|
||||
}
|
||||
if ($weight <= 300) {
|
||||
return ['result' => '400K'];
|
||||
}
|
||||
if ($weight <= 424) {
|
||||
return ['result' => '500K'];
|
||||
}
|
||||
if ($weight <= 508) {
|
||||
return ['result' => '600K'];
|
||||
}
|
||||
if ($weight <= 800) {
|
||||
return ['result' => '800K'];
|
||||
}
|
||||
if ($weight <= 1000) {
|
||||
return ['result' => '1000K'];
|
||||
}
|
||||
}
|
||||
|
||||
return ['result' => '미정의'];
|
||||
@@ -168,11 +222,11 @@ protected function executeSimpleMath(string $formula, array $variables): float
|
||||
// 변수 치환
|
||||
$expression = $formula;
|
||||
foreach ($variables as $key => $value) {
|
||||
$expression = str_replace($key, (string)$value, $expression);
|
||||
$expression = str_replace($key, (string) $value, $expression);
|
||||
}
|
||||
|
||||
// 안전한 수학 표현식 검증
|
||||
if (!$this->isSafeMathExpression($expression)) {
|
||||
if (! $this->isSafeMathExpression($expression)) {
|
||||
throw new \InvalidArgumentException("안전하지 않은 수학 표현식: {$expression}");
|
||||
}
|
||||
|
||||
@@ -197,9 +251,9 @@ protected function executeConditionalExpression(string $formula, array $variable
|
||||
|
||||
// 조건 평가
|
||||
if ($this->evaluateCondition($condition, $variables)) {
|
||||
return is_numeric($trueValue) ? (float)$trueValue : $this->execute($trueValue, $variables)['result'];
|
||||
return is_numeric($trueValue) ? (float) $trueValue : $this->execute($trueValue, $variables)['result'];
|
||||
} else {
|
||||
return is_numeric($falseValue) ? (float)$falseValue : $this->execute($falseValue, $variables)['result'];
|
||||
return is_numeric($falseValue) ? (float) $falseValue : $this->execute($falseValue, $variables)['result'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,11 +268,11 @@ protected function evaluateCondition(string $condition, array $variables): bool
|
||||
// 변수 치환
|
||||
$expression = $condition;
|
||||
foreach ($variables as $key => $value) {
|
||||
$expression = str_replace($key, (string)$value, $expression);
|
||||
$expression = str_replace($key, (string) $value, $expression);
|
||||
}
|
||||
|
||||
// 안전한 조건식 검증
|
||||
if (!$this->isSafeConditionExpression($expression)) {
|
||||
if (! $this->isSafeConditionExpression($expression)) {
|
||||
throw new \InvalidArgumentException("안전하지 않은 조건식: {$expression}");
|
||||
}
|
||||
|
||||
@@ -304,7 +358,7 @@ protected function calculateMotorBracketSize(array $variables): array
|
||||
'bracket_size' => $bracketSize,
|
||||
'motor_capacity' => $motorCapacity,
|
||||
'calculated_weight' => $weight,
|
||||
'shaft_inch' => $inch
|
||||
'shaft_inch' => $inch,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -321,7 +375,7 @@ protected function isPreDefinedFunction(string $formula): bool
|
||||
'motor_bracket_size',
|
||||
'round_bar_quantity',
|
||||
'shaft_size_determination',
|
||||
'motor_capacity_determination'
|
||||
'motor_capacity_determination',
|
||||
];
|
||||
|
||||
return in_array($formula, $predefinedFunctions);
|
||||
@@ -368,6 +422,7 @@ protected function isSafeConditionExpression(string $expression): bool
|
||||
{
|
||||
// 허용된 연산자: ==, !=, <, >, <=, >=, &&, ||
|
||||
$allowedPattern = '/^[0-9+\-*\/().\s<>=!&|]+$/';
|
||||
|
||||
return preg_match($allowedPattern, $expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user