Skip to content

Commit 9bd2921

Browse files
chore: reduce code complexity
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 20a8a1e commit 9bd2921

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/Helper/ValidateHelper.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,16 +546,22 @@ private function normalizeIdentifyMethods(array $signer): array {
546546
$normalizedMethods = [];
547547

548548
foreach ($signer[$key] as $name => $data) {
549-
if ($key === 'identifyMethods') {
550-
$normalizedMethods[] = $this->normalizeIdentifyMethodsStructure($data);
551-
} else {
552-
$normalizedMethods[] = $this->normalizeIdentifyStructure($name, $data);
553-
}
549+
$normalizedMethods[] = $this->normalizeIdentifyMethodEntry($key, $name, $data);
554550
}
555-
556551
return $normalizedMethods;
557552
}
558553

554+
/**
555+
* Extracted from normalizeIdentifyMethods to reduce cyclomatic complexity.
556+
*/
557+
private function normalizeIdentifyMethodEntry(string $key, $name, $data): array {
558+
if ($key === 'identifyMethods') {
559+
return $this->normalizeIdentifyMethodsStructure($data);
560+
} else {
561+
return $this->normalizeIdentifyStructure($name, $data);
562+
}
563+
}
564+
559565
private function normalizeIdentifyMethodsStructure(mixed $data): array {
560566
if (!is_array($data) || !array_key_exists('method', $data) || !array_key_exists('value', $data)) {
561567
throw new LibresignException('Invalid identify method structure');

0 commit comments

Comments
 (0)