Skip to content

Commit a3f9b3e

Browse files
committed
refactor(validation): simplify exception formatting and remove unused import
- Consolidated multiline `InvalidArgumentException` calls into single-line for readability. - Removed unused `FHIRValidationService` import from `FHIRValidationReportMapper`.
1 parent 6b1f22d commit a3f9b3e

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

src/Component/Validation/src/FHIRValidationReportMapper.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Ardenexal\FHIRTools\Component\Metadata\Attribute\Validation\FHIRPathInvariant;
88
use Ardenexal\FHIRTools\Component\Metadata\Attribute\Validation\FHIRValueSetBinding;
9-
use Ardenexal\FHIRTools\Component\Validation\FHIRValidationService;
109
use Ardenexal\FHIRTools\Component\Models\R4\DataType\IssueSeverityType as R4IssueSeverityType;
1110
use Ardenexal\FHIRTools\Component\Models\R4\DataType\IssueTypeType as R4IssueTypeType;
1211
use Ardenexal\FHIRTools\Component\Models\R4\Resource\OperationOutcome\OperationOutcomeIssue as R4Issue;
@@ -42,9 +41,7 @@ public function toOperationOutcome(
4241
'R4' => $this->buildR4($report->violations),
4342
'R4B' => $this->buildR4B($report->violations),
4443
'R5' => $this->buildR5($report->violations),
45-
default => throw new \InvalidArgumentException(
46-
sprintf('Unsupported FHIR version "%s". Supported values: R4, R4B, R5.', $fhirVersion),
47-
),
44+
default => throw new \InvalidArgumentException(sprintf('Unsupported FHIR version "%s". Supported values: R4, R4B, R5.', $fhirVersion)),
4845
};
4946
}
5047

@@ -116,8 +113,8 @@ private function mapSeverity(string $severity): string
116113

117114
private function mapIssueType(FHIRValidationViolation $violation): string
118115
{
119-
if ($violation->code === FHIRViolationCode::EVAL_ERROR
120-
|| $violation->code === FHIRViolationCode::UNCHECKED_BINDING
116+
if ($violation->code === FHIRViolationCode::EVAL_ERROR
117+
|| $violation->code === FHIRViolationCode::UNCHECKED_BINDING
121118
|| $violation->constraintClass === FHIRValidationService::class) {
122119
return 'not-supported';
123120
}

src/Component/Validation/src/FHIRValidationService.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ public function validateForOperation(
103103
string $fhirVersion = 'R4',
104104
): object {
105105
if (!in_array($mode, ['', 'create', 'update', 'profile', 'delete'], true)) {
106-
throw new \InvalidArgumentException(
107-
sprintf('Unsupported mode "%s". Supported values: \'\', create, update, profile, delete.', $mode),
108-
);
106+
throw new \InvalidArgumentException(sprintf('Unsupported mode "%s". Supported values: \'\', create, update, profile, delete.', $mode));
109107
}
110108

111109
if ($mode === 'delete') {

0 commit comments

Comments
 (0)