File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ public function __construct(
13
13
private string $ filename ,
14
14
#[SensitiveParameter] private string $ secret
15
15
) {
16
+ if (!file_exists ($ this ->filename )) {
17
+ throw new FileEncryptorException ("File not found " );
18
+ }
16
19
}
17
20
18
21
/**
@@ -26,7 +29,7 @@ public function encryptFile(): bool
26
29
$ plainText = file_get_contents ($ this ->filename );
27
30
28
31
if (!$ plainText ) {
29
- throw new FileEncryptorException ('File not found or has no content ' );
32
+ throw new FileEncryptorException ('File has no content ' );
30
33
}
31
34
if (ctype_xdigit ($ plainText )) {
32
35
throw new FileEncryptorException ('file is already encrypted ' );
@@ -65,7 +68,7 @@ public function decryptFile(): bool
65
68
$ encryptedData = file_get_contents ($ this ->filename );
66
69
67
70
if (!$ encryptedData ) {
68
- throw new FileEncryptorException ('File not found or has no content ' );
71
+ throw new FileEncryptorException ('File has no content ' );
69
72
}
70
73
71
74
if (!ctype_xdigit ($ encryptedData )) {
You can’t perform that action at this time.
0 commit comments