From 24e4a79666ce4c48e53b009300d8358c0ad803c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin?= Date: Thu, 25 May 2023 14:21:12 +0200 Subject: [PATCH] Refacto/add type exceptions (#695) * Refacto: Type Exceptions class * fix pedro review --- src/Gaufrette/Exception/FileAlreadyExists.php | 10 +++++----- src/Gaufrette/Exception/FileNotFound.php | 10 +++++----- src/Gaufrette/Exception/UnexpectedFile.php | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Gaufrette/Exception/FileAlreadyExists.php b/src/Gaufrette/Exception/FileAlreadyExists.php index b58b5337b..3f51c5528 100644 --- a/src/Gaufrette/Exception/FileAlreadyExists.php +++ b/src/Gaufrette/Exception/FileAlreadyExists.php @@ -11,20 +11,20 @@ */ class FileAlreadyExists extends \RuntimeException implements Exception { - private $key; + private string $key; - public function __construct($key, $code = 0, \Exception $previous = null) + public function __construct(string $key, int $code = 0, \Exception $previous = null) { - $this->key = $key; - parent::__construct( sprintf('The file %s already exists and can not be overwritten.', $key), $code, $previous ); + + $this->key = $key; } - public function getKey() + public function getKey(): string { return $this->key; } diff --git a/src/Gaufrette/Exception/FileNotFound.php b/src/Gaufrette/Exception/FileNotFound.php index 840ab9971..cef80efca 100644 --- a/src/Gaufrette/Exception/FileNotFound.php +++ b/src/Gaufrette/Exception/FileNotFound.php @@ -11,20 +11,20 @@ */ class FileNotFound extends \RuntimeException implements Exception { - private $key; + private string $key; - public function __construct($key, $code = 0, \Exception $previous = null) + public function __construct(string $key, int $code = 0, \Exception $previous = null) { - $this->key = $key; - parent::__construct( sprintf('The file "%s" was not found.', $key), $code, $previous ); + + $this->key = $key; } - public function getKey() + public function getKey(): string { return $this->key; } diff --git a/src/Gaufrette/Exception/UnexpectedFile.php b/src/Gaufrette/Exception/UnexpectedFile.php index 38749c2fe..8872f9838 100644 --- a/src/Gaufrette/Exception/UnexpectedFile.php +++ b/src/Gaufrette/Exception/UnexpectedFile.php @@ -11,20 +11,20 @@ */ class UnexpectedFile extends \RuntimeException implements Exception { - private $key; + private string $key; - public function __construct($key, $code = 0, \Exception $previous = null) + public function __construct(string $key, int $code = 0, \Exception $previous = null) { - $this->key = $key; - parent::__construct( sprintf('The file "%s" was not supposed to exist.', $key), $code, $previous ); + + $this->key = $key; } - public function getKey() + public function getKey(): string { return $this->key; }