diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php index 0db72ed3a2..9eecde245b 100644 --- a/app/Export/Collector/AttachmentCollector.php +++ b/app/Export/Collector/AttachmentCollector.php @@ -1,5 +1,4 @@ end = $end; } + /** @noinspection MultipleReturnStatementsInspection */ /** + * Export attachments. + * * @param Attachment $attachment * * @return bool @@ -101,13 +108,13 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface if ($this->uploadDisk->exists($file)) { try { $decrypted = Crypt::decrypt($this->uploadDisk->get($file)); - } catch (DecryptException $e) { + } catch (FileNotFoundException|DecryptException $e) { Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage()); return false; } } - if ($decrypted === false) { + if (false === $decrypted) { return false; } $exportFile = $this->exportFileName($attachment); @@ -130,6 +137,8 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface } /** + * Get the attachments. + * * @return Collection */ private function getAttachments(): Collection diff --git a/app/Export/Collector/BasicCollector.php b/app/Export/Collector/BasicCollector.php index bc19f1f541..10215d6c58 100644 --- a/app/Export/Collector/BasicCollector.php +++ b/app/Export/Collector/BasicCollector.php @@ -33,11 +33,11 @@ use Illuminate\Support\Collection; */ class BasicCollector { - /** @var ExportJob */ + /** @var ExportJob The job to export. */ protected $job; - /** @var User */ + /** @var User The user */ protected $user; - /** @var Collection */ + /** @var Collection All the entries. */ private $entries; /** @@ -49,6 +49,8 @@ class BasicCollector } /** + * Get all entries. + * * @return Collection */ public function getEntries(): Collection @@ -57,26 +59,32 @@ class BasicCollector } /** + * Set entries. + * * @param Collection $entries */ - public function setEntries(Collection $entries) + public function setEntries(Collection $entries): void { $this->entries = $entries; } /** + * Set export job. + * * @param ExportJob $job */ - public function setJob(ExportJob $job) + public function setJob(ExportJob $job): void { $this->job = $job; $this->user = $job->user; } /** + * Set user. + * * @param User $user */ - public function setUser(User $user) + public function setUser(User $user): void { $this->user = $user; } diff --git a/app/Export/Collector/CollectorInterface.php b/app/Export/Collector/CollectorInterface.php index bd40c82f29..b93dc1617b 100644 --- a/app/Export/Collector/CollectorInterface.php +++ b/app/Export/Collector/CollectorInterface.php @@ -33,21 +33,29 @@ use Illuminate\Support\Collection; interface CollectorInterface { /** + * Get entries. + * * @return Collection */ public function getEntries(): Collection; /** + * Run the collector. + * * @return bool */ public function run(): bool; /** + * Set entries. + * * @param Collection $entries */ public function setEntries(Collection $entries); /** + * Set export job. + * * @param ExportJob $job * * @return mixed diff --git a/app/Export/Collector/UploadCollector.php b/app/Export/Collector/UploadCollector.php index dd8c71e769..5e1e6df02b 100644 --- a/app/Export/Collector/UploadCollector.php +++ b/app/Export/Collector/UploadCollector.php @@ -1,5 +1,4 @@ . */ +/** @noinspection PhpDynamicAsStaticMethodCallInspection */ + declare(strict_types=1); namespace FireflyIII\Export; @@ -50,23 +51,23 @@ use ZipArchive; */ class ExpandedProcessor implements ProcessorInterface { - /** @var Collection */ + /** @var Collection All accounts */ public $accounts; - /** @var string */ + /** @var string The export format*/ public $exportFormat; - /** @var bool */ + /** @var bool Should include attachments */ public $includeAttachments; - /** @var bool */ + /** @var bool Should include old uploads */ public $includeOldUploads; - /** @var ExportJob */ + /** @var ExportJob The export job itself */ public $job; - /** @var array */ + /** @var array The settings*/ public $settings; - /** @var Collection */ + /** @var Collection The entries to export. */ private $exportEntries; - /** @var Collection */ + /** @var Collection The files to export */ private $files; - /** @var Collection */ + /** @var Collection The journals. */ private $journals; /** @@ -80,6 +81,8 @@ class ExpandedProcessor implements ProcessorInterface } /** + * Collect all attachments + * * @return bool */ public function collectAttachments(): bool @@ -143,6 +146,8 @@ class ExpandedProcessor implements ProcessorInterface } /** + * Get old oploads. + * * @return bool */ public function collectOldUploads(): bool @@ -158,6 +163,8 @@ class ExpandedProcessor implements ProcessorInterface } /** + * Convert journals to export objects. + * * @return bool */ public function convertJournals(): bool @@ -173,6 +180,8 @@ class ExpandedProcessor implements ProcessorInterface } /** + * Create a ZIP file. + * * @return bool * * @throws FireflyException @@ -204,6 +213,8 @@ class ExpandedProcessor implements ProcessorInterface } /** + * Export the journals. + * * @return bool */ public function exportJournals(): bool @@ -219,6 +230,8 @@ class ExpandedProcessor implements ProcessorInterface } /** + * Get files. + * * @return Collection */ public function getFiles(): Collection @@ -231,7 +244,7 @@ class ExpandedProcessor implements ProcessorInterface * * @param array $settings */ - public function setSettings(array $settings) + public function setSettings(array $settings): void { // save settings $this->settings = $settings; @@ -243,9 +256,9 @@ class ExpandedProcessor implements ProcessorInterface } /** - * + * Delete files. */ - private function deleteFiles() + private function deleteFiles():void { $disk = Storage::disk('export'); foreach ($this->getFiles() as $file) { @@ -254,6 +267,8 @@ class ExpandedProcessor implements ProcessorInterface } /** + * Get currencies. + * * @param array $array * * @return array diff --git a/app/Export/Exporter/BasicExporter.php b/app/Export/Exporter/BasicExporter.php index 02826171c2..fd1003ddfa 100644 --- a/app/Export/Exporter/BasicExporter.php +++ b/app/Export/Exporter/BasicExporter.php @@ -32,9 +32,9 @@ use Illuminate\Support\Collection; */ class BasicExporter { - /** @var ExportJob */ + /** @var ExportJob The export job */ protected $job; - /** @var Collection */ + /** @var Collection The entries */ private $entries; /** @@ -46,6 +46,8 @@ class BasicExporter } /** + * Get all entries. + * * @return Collection */ public function getEntries(): Collection @@ -54,17 +56,21 @@ class BasicExporter } /** + * Set all entries. + * * @param Collection $entries */ - public function setEntries(Collection $entries) + public function setEntries(Collection $entries): void { $this->entries = $entries; } /** + * Set the job. + * * @param ExportJob $job */ - public function setJob(ExportJob $job) + public function setJob(ExportJob $job): void { $this->job = $job; } diff --git a/app/Export/Exporter/CsvExporter.php b/app/Export/Exporter/CsvExporter.php index e323b94bf9..bbc66b8345 100644 --- a/app/Export/Exporter/CsvExporter.php +++ b/app/Export/Exporter/CsvExporter.php @@ -33,10 +33,12 @@ use Storage; */ class CsvExporter extends BasicExporter implements ExporterInterface { - /** @var string */ + /** @var string Filename */ private $fileName; /** + * Get file name. + * * @return string */ public function getFileName(): string @@ -45,6 +47,8 @@ class CsvExporter extends BasicExporter implements ExporterInterface } /** + * Run collector. + * * @return bool * */ @@ -83,6 +87,9 @@ class CsvExporter extends BasicExporter implements ExporterInterface return true; } + /** + * Make a temp file. + */ private function tempFile() { $this->fileName = $this->job->key . '-records.csv'; diff --git a/app/Export/Exporter/ExporterInterface.php b/app/Export/Exporter/ExporterInterface.php index f10e763dab..cc44b69c08 100644 --- a/app/Export/Exporter/ExporterInterface.php +++ b/app/Export/Exporter/ExporterInterface.php @@ -33,26 +33,36 @@ use Illuminate\Support\Collection; interface ExporterInterface { /** + * Get entries. + * * @return Collection */ public function getEntries(): Collection; /** + * Get file name. + * * @return string */ public function getFileName(): string; /** + * Run exporter. + * * @return bool */ public function run(): bool; /** + * Set entries. + * * @param Collection $entries */ public function setEntries(Collection $entries); /** + * Set job. + * * @param ExportJob $job */ public function setJob(ExportJob $job); diff --git a/app/Export/ProcessorInterface.php b/app/Export/ProcessorInterface.php index ad8745cc7c..641e26eaeb 100644 --- a/app/Export/ProcessorInterface.php +++ b/app/Export/ProcessorInterface.php @@ -37,41 +37,57 @@ interface ProcessorInterface public function __construct(); /** + * Collect all attachments. + * * @return bool */ public function collectAttachments(): bool; /** + * Collect all journals. + * * @return bool */ public function collectJournals(): bool; /** + * Collect old uploads. + * * @return bool */ public function collectOldUploads(): bool; /** + * Convert all journals. + * * @return bool */ public function convertJournals(): bool; /** + * Create a zip file. + * * @return bool */ public function createZipFile(): bool; /** + * Export journals. + * * @return bool */ public function exportJournals(): bool; /** + * Get all files. + * * @return Collection */ public function getFiles(): Collection; /** + * Set the settings. + * * @param array $settings */ public function setSettings(array $settings);