From 12f99aa2b78332a62a3e0b82d41c6803a55e0f6b Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Sun, 13 Oct 2024 09:23:27 +0100 Subject: [PATCH] style: apply fixes from ECS --- src/Enums/ExportResponseStatus.php | 1 + src/Enums/ExportStatus.php | 1 + src/Generator/CsvDriver.php | 1 + src/Processor/ProcessorRepository.php | 2 +- src/Services/CreateExport.php | 2 +- .../Fake/FakeProcessorWithOptionalDriver.php | 2 +- .../Processor/EloquentProcessorTest.php | 20 +++++++++---------- tests/Feature/Processor/ProcessorDataTest.php | 2 +- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Enums/ExportResponseStatus.php b/src/Enums/ExportResponseStatus.php index 8a0c057..f101e6f 100644 --- a/src/Enums/ExportResponseStatus.php +++ b/src/Enums/ExportResponseStatus.php @@ -11,5 +11,6 @@ final class ExportResponseStatus extends Enum { public const SUCCESS = 'success'; + public const ERROR = 'error'; } diff --git a/src/Enums/ExportStatus.php b/src/Enums/ExportStatus.php index 446e88f..78ccc71 100644 --- a/src/Enums/ExportStatus.php +++ b/src/Enums/ExportStatus.php @@ -7,5 +7,6 @@ final class ExportStatus extends Enum { public const AWAITING = 'awaiting'; + public const COMPLETED = 'completed'; } diff --git a/src/Generator/CsvDriver.php b/src/Generator/CsvDriver.php index 7be58bc..c539c68 100644 --- a/src/Generator/CsvDriver.php +++ b/src/Generator/CsvDriver.php @@ -25,6 +25,7 @@ public function generate(ProcessorData $processorData): GeneratorFile Carbon::now()->format('Y-m-d'), Str::random(40) ); + return $this->saveToStorage($filename, $csv, $processorData); } diff --git a/src/Processor/ProcessorRepository.php b/src/Processor/ProcessorRepository.php index 1cabe2e..ee2347c 100644 --- a/src/Processor/ProcessorRepository.php +++ b/src/Processor/ProcessorRepository.php @@ -22,7 +22,7 @@ public function get(string $processor): ProcessorDriver { if (! isset($this->processors[$processor])) { throw new InvalidProcessorException( - sprintf("The processor [%s] is not registered!", $processor) + sprintf('The processor [%s] is not registered!', $processor) ); } diff --git a/src/Services/CreateExport.php b/src/Services/CreateExport.php index 3665dcf..be4f924 100644 --- a/src/Services/CreateExport.php +++ b/src/Services/CreateExport.php @@ -38,7 +38,7 @@ public function run(): Export 'dateTo' => $dateTo, 'dateFrom' => $dateFrom, ] - ) + ), ]); } } diff --git a/tests/Fake/FakeProcessorWithOptionalDriver.php b/tests/Fake/FakeProcessorWithOptionalDriver.php index 4c8acd9..504e58b 100644 --- a/tests/Fake/FakeProcessorWithOptionalDriver.php +++ b/tests/Fake/FakeProcessorWithOptionalDriver.php @@ -30,7 +30,7 @@ public function optional($item): array { return [ ['Compliance UK' => 'applies'], - ['Compliance US' => 'none'] + ['Compliance US' => 'none'], ]; } } diff --git a/tests/Feature/Processor/EloquentProcessorTest.php b/tests/Feature/Processor/EloquentProcessorTest.php index ddcde06..dd18915 100644 --- a/tests/Feature/Processor/EloquentProcessorTest.php +++ b/tests/Feature/Processor/EloquentProcessorTest.php @@ -74,18 +74,18 @@ } expect($data[0])->toBe([ - "User ID" => "1", - "name" => "User One", - "Is Admin" => "1", - "Compliance UK" => "applies", - "Compliance US" => "none" + 'User ID' => '1', + 'name' => 'User One', + 'Is Admin' => '1', + 'Compliance UK' => 'applies', + 'Compliance US' => 'none', ]); expect($data[1])->toBe([ - "User ID" => "2", - "name" => "User Two", - "Is Admin" => "0", - "Compliance UK" => "applies", - "Compliance US" => "none" + 'User ID' => '2', + 'name' => 'User Two', + 'Is Admin' => '0', + 'Compliance UK' => 'applies', + 'Compliance US' => 'none', ]); }); diff --git a/tests/Feature/Processor/ProcessorDataTest.php b/tests/Feature/Processor/ProcessorDataTest.php index fdb96c5..4027f88 100644 --- a/tests/Feature/Processor/ProcessorDataTest.php +++ b/tests/Feature/Processor/ProcessorDataTest.php @@ -6,7 +6,7 @@ it('can retrieve the data', function () { $processorData = new ProcessorData([ - 'foo' => 'Bar' + 'foo' => 'Bar', ], 'randomstuff'); expect($processorData->getData())->toBe([