From ea85dc8eefaf00ca5b1a9eecb763c719c86b3b5b Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Wed, 2 Oct 2024 16:14:58 +0200 Subject: [PATCH 1/2] Adding more dedicated exceptions --- src/Smalot/PdfParser/Exception/EmptyPdfException.php | 7 +++++++ .../PdfParser/Exception/MissingPdfHeaderException.php | 7 +++++++ src/Smalot/PdfParser/RawData/RawDataParser.php | 10 ++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/Smalot/PdfParser/Exception/EmptyPdfException.php create mode 100644 src/Smalot/PdfParser/Exception/MissingPdfHeaderException.php diff --git a/src/Smalot/PdfParser/Exception/EmptyPdfException.php b/src/Smalot/PdfParser/Exception/EmptyPdfException.php new file mode 100644 index 00000000..1fc8464f --- /dev/null +++ b/src/Smalot/PdfParser/Exception/EmptyPdfException.php @@ -0,0 +1,7 @@ + Date: Thu, 31 Oct 2024 09:27:58 +0100 Subject: [PATCH 2/2] Refined new exceptions; added NotImplementedException also fixed some coding style issues --- .../PdfParser/Exception/EmptyPdfException.php | 7 ++++++- .../Exception/MissingPdfHeaderException.php | 7 ++++++- .../Exception/NotImplementedException.php | 12 ++++++++++++ src/Smalot/PdfParser/RawData/FilterHelper.php | 15 +++++++++------ src/Smalot/PdfParser/RawData/RawDataParser.php | 2 +- 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 src/Smalot/PdfParser/Exception/NotImplementedException.php diff --git a/src/Smalot/PdfParser/Exception/EmptyPdfException.php b/src/Smalot/PdfParser/Exception/EmptyPdfException.php index 1fc8464f..9eda9ce2 100644 --- a/src/Smalot/PdfParser/Exception/EmptyPdfException.php +++ b/src/Smalot/PdfParser/Exception/EmptyPdfException.php @@ -1,7 +1,12 @@ -decodeFilterRunLengthDecode($data); case 'CCITTFaxDecode': - throw new \Exception('Decode CCITTFaxDecode not implemented yet.'); + throw new NotImplementedException('Decode CCITTFaxDecode not implemented yet.'); case 'JBIG2Decode': - throw new \Exception('Decode JBIG2Decode not implemented yet.'); + throw new NotImplementedException('Decode JBIG2Decode not implemented yet.'); case 'DCTDecode': - throw new \Exception('Decode DCTDecode not implemented yet.'); + throw new NotImplementedException('Decode DCTDecode not implemented yet.'); case 'JPXDecode': - throw new \Exception('Decode JPXDecode not implemented yet.'); + throw new NotImplementedException('Decode JPXDecode not implemented yet.'); case 'Crypt': - throw new \Exception('Decode Crypt not implemented yet.'); + throw new NotImplementedException('Decode Crypt not implemented yet.'); default: return $data; } diff --git a/src/Smalot/PdfParser/RawData/RawDataParser.php b/src/Smalot/PdfParser/RawData/RawDataParser.php index bb8a0a9a..a94be8a7 100644 --- a/src/Smalot/PdfParser/RawData/RawDataParser.php +++ b/src/Smalot/PdfParser/RawData/RawDataParser.php @@ -43,8 +43,8 @@ namespace Smalot\PdfParser\RawData; use Smalot\PdfParser\Config; -use Smalot\PdfParser\Exception\MissingPdfHeaderException; use Smalot\PdfParser\Exception\EmptyPdfException; +use Smalot\PdfParser\Exception\MissingPdfHeaderException; class RawDataParser {