Skip to content

Commit 957114b

Browse files
committed
refactor: update DocMdpHandler to use new enum names
Update all references to DocMdpLevel enum cases: - NONE → NOT_CERTIFIED - NO_CHANGES → CERTIFIED_NO_CHANGES_ALLOWED - FORM_FILL → CERTIFIED_FORM_FILLING - FORM_FILL_AND_ANNOTATIONS → CERTIFIED_FORM_FILLING_AND_ANNOTATIONS Updated in: - ALLOWED_MODIFICATIONS constant - extractDocMdpLevel() fallback values - getAllowedModificationMessage() match expression - getViolationMessage() match expression - validateModifications() condition checks Signed-off-by: Vitor Mattos <[email protected]>
1 parent ae1d611 commit 957114b

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

lib/Handler/DocMdpHandler.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
class DocMdpHandler {
1717
/** @var array<string, string[]> Allowed modification types per DocMDP level */
1818
private const ALLOWED_MODIFICATIONS = [
19-
'NO_CHANGES' => [],
20-
'FORM_FILL' => ['form_field', 'template', 'signature'],
21-
'FORM_FILL_AND_ANNOTATIONS' => ['form_field', 'template', 'annotation', 'signature'],
19+
'CERTIFIED_NO_CHANGES_ALLOWED' => [],
20+
'CERTIFIED_FORM_FILLING' => ['form_field', 'template', 'signature'],
21+
'CERTIFIED_FORM_FILLING_AND_ANNOTATIONS' => ['form_field', 'template', 'annotation', 'signature'],
2222
];
2323

2424
public function __construct(
@@ -70,15 +70,15 @@ private function extractDocMdpLevel($pdfResource): DocMdpLevel {
7070
$content = stream_get_contents($pdfResource);
7171

7272
if (!$this->validateIsoCompliance($content)) {
73-
return DocMdpLevel::NONE;
73+
return DocMdpLevel::NOT_CERTIFIED;
7474
}
7575

7676
$pValue = $this->extractPValue($content);
7777
if ($pValue === null) {
78-
return DocMdpLevel::NONE;
78+
return DocMdpLevel::NOT_CERTIFIED;
7979
}
8080

81-
return DocMdpLevel::tryFrom($pValue) ?? DocMdpLevel::NONE;
81+
return DocMdpLevel::tryFrom($pValue) ?? DocMdpLevel::NOT_CERTIFIED;
8282
}
8383

8484
/**
@@ -249,7 +249,7 @@ private function validateModifications(DocMdpLevel $docmdpLevel, array $modifica
249249
);
250250
}
251251

252-
if ($docmdpLevel === DocMdpLevel::NONE) {
252+
if ($docmdpLevel === DocMdpLevel::NOT_CERTIFIED) {
253253
return $this->buildValidationResult(
254254
true,
255255
File::MODIFICATION_ALLOWED,
@@ -307,9 +307,9 @@ private function buildValidationResult(bool $valid, int $status, string $message
307307
*/
308308
private function getAllowedModificationMessage(DocMdpLevel $level): string {
309309
return match ($level) {
310-
DocMdpLevel::NO_CHANGES => 'Invalid: Document was modified after signing (DocMDP violation - no changes allowed)',
311-
DocMdpLevel::FORM_FILL => 'Document form fields were modified (allowed by DocMDP P=2)',
312-
DocMdpLevel::FORM_FILL_AND_ANNOTATIONS => 'Document form fields or annotations were modified (allowed by DocMDP P=3)',
310+
DocMdpLevel::CERTIFIED_NO_CHANGES_ALLOWED => 'Invalid: Document was modified after signing (DocMDP violation - no changes allowed)',
311+
DocMdpLevel::CERTIFIED_FORM_FILLING => 'Document form fields were modified (allowed by DocMDP P=2)',
312+
DocMdpLevel::CERTIFIED_FORM_FILLING_AND_ANNOTATIONS => 'Document form fields or annotations were modified (allowed by DocMDP P=3)',
313313
default => 'Document was modified after signing',
314314
};
315315
}
@@ -322,9 +322,9 @@ private function getAllowedModificationMessage(DocMdpLevel $level): string {
322322
*/
323323
private function getViolationMessage(DocMdpLevel $level): string {
324324
return match ($level) {
325-
DocMdpLevel::NO_CHANGES => 'Invalid: Document was modified after signing (DocMDP violation - no changes allowed)',
326-
DocMdpLevel::FORM_FILL => 'Invalid: Document was modified after signing (DocMDP P=2 only allows form field changes)',
327-
DocMdpLevel::FORM_FILL_AND_ANNOTATIONS => 'Invalid: Document was modified after signing (DocMDP P=3 only allows form fields and annotations)',
325+
DocMdpLevel::CERTIFIED_NO_CHANGES_ALLOWED => 'Invalid: Document was modified after signing (DocMDP violation - no changes allowed)',
326+
DocMdpLevel::CERTIFIED_FORM_FILLING => 'Invalid: Document was modified after signing (DocMDP P=2 only allows form field changes)',
327+
DocMdpLevel::CERTIFIED_FORM_FILLING_AND_ANNOTATIONS => 'Invalid: Document was modified after signing (DocMDP P=3 only allows form fields and annotations)',
328328
default => 'Invalid: Document was modified after signing (DocMDP violation)',
329329
};
330330
}

0 commit comments

Comments
 (0)