* create new threshold for dataset * * @param int $reportId * @param $dimension * @param $option * @param $value * @param int $severity * @param $coloring * @return int * @throws Exception */
(int $reportId, $dimension, $option, $value, int $severity, $coloring, ?string $sourceColumnRef = null)
| 85 | * @throws Exception |
| 86 | */ |
| 87 | public function create(int $reportId, $dimension, $option, $value, int $severity, $coloring, ?string $sourceColumnRef = null) { |
| 88 | $report = $this->ReportMapper->readOwn($reportId); |
| 89 | if (empty($report)) { |
| 90 | return 0; |
| 91 | } |
| 92 | if ((int)($report['dataset'] ?? 0) > 0) { |
| 93 | $storage = $this->DatasetStorageResolver->resolve((int)$report['dataset'], true); |
| 94 | if ($storage['mode'] === DatasetStorageResolver::FLEXIBLE_SHARED) { |
| 95 | if ($sourceColumnRef === null) { |
| 96 | throw new FlexibleStorageException('missing_threshold_column', 'Flexible thresholds require a source column reference.', ['field' => 'sourceColumnRef']); |
| 97 | } |
| 98 | (new FlexibleColumnResolver($this->FlexibleStorageMapper->getColumns((int)$report['dataset'])))->resolve($sourceColumnRef); |
| 99 | } elseif ($sourceColumnRef !== null) { |
| 100 | throw new FlexibleStorageException('invalid_threshold_column', 'Source column references are available only for flexible datasets.', ['field' => 'sourceColumnRef']); |
| 101 | } |
| 102 | } elseif ($sourceColumnRef !== null) { |
| 103 | throw new FlexibleStorageException('invalid_threshold_column', 'Source column references are available only for flexible datasets.', ['field' => 'sourceColumnRef']); |
| 104 | } |
| 105 | $this->ReportMapper->increaseVersionByReport($reportId); |
| 106 | return $this->ThresholdMapper->create($reportId, $dimension, $value, $option, $severity, $coloring, $sourceColumnRef); |
| 107 | } |
| 108 | |
| 109 | private function floatvalue($val) { |
| 110 | // if value is a 3 digit comma number with one leading zero like 0,111, it should not go through the 1000 separator removal |
nothing calls this directly
no test coverage detected