File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ public function __construct(
1313 private string $ filename ,
1414 #[SensitiveParameter] private string $ secret
1515 ) {
16+ if (!file_exists ($ this ->filename )) {
17+ throw new FileEncryptorException ("File not found " );
18+ }
1619 }
1720
1821 /**
@@ -26,7 +29,7 @@ public function encryptFile(): bool
2629 $ plainText = file_get_contents ($ this ->filename );
2730
2831 if (!$ plainText ) {
29- throw new FileEncryptorException ('File not found or has no content ' );
32+ throw new FileEncryptorException ('File has no content ' );
3033 }
3134 if (ctype_xdigit ($ plainText )) {
3235 throw new FileEncryptorException ('file is already encrypted ' );
@@ -65,7 +68,7 @@ public function decryptFile(): bool
6568 $ encryptedData = file_get_contents ($ this ->filename );
6669
6770 if (!$ encryptedData ) {
68- throw new FileEncryptorException ('File not found or has no content ' );
71+ throw new FileEncryptorException ('File has no content ' );
6972 }
7073
7174 if (!ctype_xdigit ($ encryptedData )) {
You can’t perform that action at this time.
0 commit comments