internal_percentage_to_deduct = getenv('PRICE_INTERNAL_PERCENTAGE_TO_DEDUCT'); $this->partner_organization = strtolower(getenv('GITEA_PARTNER_ORGANIZATION')); $this->price_partner = [ 'high' => $this->calculate_minute_cost((int)getenv('PRICE_PARTNER_HIGH')), 'normal' => $this->calculate_minute_cost((int)getenv('PRICE_PARTNER_NORMAL')), 'low' => $this->calculate_minute_cost((int)getenv('PRICE_PARTNER_LOW')), '0'=>0, ]; $this->price_client = [ 'high' => $this->calculate_minute_cost((int)getenv('PRICE_CLIENT_HIGH')), 'normal' => $this->calculate_minute_cost((int)getenv('PRICE_CLIENT_NORMAL')), 'low' => $this->calculate_minute_cost((int)getenv('PRICE_CLIENT_LOW')), '0'=>0, ]; } private function calculate_minute_cost(int $hourly_cost) { return $hourly_cost / 60; } private function extract_string_from_label($label) { return strtolower(substr($label, strpos($label, '/') + 1)); } function select_correct_cost($requested_by, $priority) { $requested_by = $this->extract_string_from_label($requested_by); $priority = $this->extract_string_from_label($priority); $requested_by_partner = str_contains($requested_by, strtolower($this->partner_organization)); try { $priority = match ($priority) { 'critical', 'high' => 'high', 'medium' => 'normal', 'low' => 'low', default =>'0' }; } catch (Exception $e) { Log::error('E-CSV-MINUTECOSTCALC - '. $e->getMessage()); } if ($requested_by_partner) { return $this->price_partner[$priority]; } return $this->price_client[$priority]; } }