From ea6beb71243d973892dcef1ca2d87cc8643cc82c Mon Sep 17 00:00:00 2001 From: Hergen Dillema Date: Fri, 30 Apr 2021 12:42:32 +0200 Subject: [PATCH 1/3] Exceptions added, small fix for creating services --- src/Commands/MakeService.php | 5 +++++ src/Exceptions/CouldNotSetService.php | 13 +++++++++++++ src/IdentityImage.php | 5 +++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/Exceptions/CouldNotSetService.php diff --git a/src/Commands/MakeService.php b/src/Commands/MakeService.php index fd51d02..17e251e 100644 --- a/src/Commands/MakeService.php +++ b/src/Commands/MakeService.php @@ -50,8 +50,13 @@ public function handle() case 'facedetection': case 'fd': $this->stubName = 'FaceDetectionServiceStub.php'; + break; case 'both': $this->stubName = 'OcrFdServiceStub.php'; + break; + default: + $this->error('Service Type not recognized, try using "OCR", "FaceDetection" or "Both"' ); + return false; } // First we need to ensure that the given name is not a reserved word within the PHP // language and that the class name will actually be valid. If it is not valid we diff --git a/src/Exceptions/CouldNotSetService.php b/src/Exceptions/CouldNotSetService.php new file mode 100644 index 0000000..2a8810c --- /dev/null +++ b/src/Exceptions/CouldNotSetService.php @@ -0,0 +1,13 @@ +implementsInterface(OCR::class)) { - dd('not ocr'); + throw CouldNotSetService::couldNotDetectInterface(OCR::class, $service); } $this->ocrService = $service; } @@ -38,7 +39,7 @@ public function setFaceDetectionService(string $service) { $class = new ReflectionClass($service); if (! $class->implementsInterface(FaceDetection::class)) { - dd('not fd'); + throw CouldNotSetService::couldNotDetectInterface(FaceDetection::class, $service); } $this->faceDetectionService = $service; } From 1adc88aa3e6e92f7c67a757182492001e4ef0fbd Mon Sep 17 00:00:00 2001 From: HergenD Date: Fri, 30 Apr 2021 10:43:31 +0000 Subject: [PATCH 2/3] Apply fixes from StyleCI --- src/Commands/MakeService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Commands/MakeService.php b/src/Commands/MakeService.php index 17e251e..a667bd5 100644 --- a/src/Commands/MakeService.php +++ b/src/Commands/MakeService.php @@ -55,7 +55,8 @@ public function handle() $this->stubName = 'OcrFdServiceStub.php'; break; default: - $this->error('Service Type not recognized, try using "OCR", "FaceDetection" or "Both"' ); + $this->error('Service Type not recognized, try using "OCR", "FaceDetection" or "Both"'); + return false; } // First we need to ensure that the given name is not a reserved word within the PHP From f0014b7c1dd28f075024a30b0b46304106bf5857 Mon Sep 17 00:00:00 2001 From: Hergen Dillema Date: Fri, 30 Apr 2021 12:44:45 +0200 Subject: [PATCH 3/3] 2.0.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 99dd750..c7ad529 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "werk365/identitydocuments", "description": "Package to parse identity documents like passports", "license": "GPL-3.0-or-later", - "version": "2.0.1", + "version": "2.0.2", "authors": [ { "name": "Hergen Dillema",