From 5d242aa2f86f003bb5f0400188a440d2d5eea68f Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Tue, 4 Jul 2023 22:13:32 +0330 Subject: Refactors files app commands. To improve code readability. Signed-off-by: Faraz Samapoor --- apps/files/lib/Command/Object/Put.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'apps/files/lib/Command/Object/Put.php') diff --git a/apps/files/lib/Command/Object/Put.php b/apps/files/lib/Command/Object/Put.php index dabc2b1ffc3..852d7c2225e 100644 --- a/apps/files/lib/Command/Object/Put.php +++ b/apps/files/lib/Command/Object/Put.php @@ -33,12 +33,10 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; class Put extends Command { - private ObjectUtil $objectUtils; - private IMimeTypeDetector $mimeTypeDetector; - - public function __construct(ObjectUtil $objectUtils, IMimeTypeDetector $mimeTypeDetector) { - $this->objectUtils = $objectUtils; - $this->mimeTypeDetector = $mimeTypeDetector; + public function __construct( + private ObjectUtil $objectUtils, + private IMimeTypeDetector $mimeTypeDetector, + ) { parent::__construct(); } @@ -75,10 +73,10 @@ class Put extends Command { $source = $inputName === '-' ? STDIN : fopen($inputName, 'r'); if (!$source) { $output->writeln("Failed to open $inputName"); - return 1; + return self::FAILURE; } $objectStore->writeObject($object, $source, $this->mimeTypeDetector->detectPath($inputName)); - return 0; + return self::SUCCESS; } } -- cgit v1.2.3