From fe3bec5caaf589a325b3e6885b0bdf5e00c87e50 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 17 Jul 2024 17:34:28 +0300 Subject: [PATCH] move MIME type constants to Filesystem model --- src/Interface/Model/Connection.php | 3 --- src/Model/Connection.php | 3 ++- src/Model/Connection/File.php | 6 +++--- src/Model/Connection/Gemini.php | 4 ++-- src/Model/Connection/Nex.php | 5 +++-- src/Model/Filesystem.php | 3 +++ 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Interface/Model/Connection.php b/src/Interface/Model/Connection.php index 53163c65..545083ca 100644 --- a/src/Interface/Model/Connection.php +++ b/src/Interface/Model/Connection.php @@ -21,9 +21,6 @@ interface Connection int $timeout = 5 ): void; - public const MIME_TEXT_GEMINI = 'text/gemini'; - public const MIME_TEXT_PLAIN = 'text/plain'; - public function isCompleted(): bool; public function setCompleted( diff --git a/src/Model/Connection.php b/src/Model/Connection.php index c4cadaed..0ed039fc 100644 --- a/src/Model/Connection.php +++ b/src/Model/Connection.php @@ -9,6 +9,7 @@ use \Yggverse\Net\Address; use \Yggverse\Yoda\Model\Connection\File; use \Yggverse\Yoda\Model\Connection\Gemini; use \Yggverse\Yoda\Model\Connection\Nex; +use \Yggverse\Yoda\Model\Filesystem; class Connection extends \Yggverse\Yoda\Abstract\Model\Connection { @@ -115,7 +116,7 @@ class Connection extends \Yggverse\Yoda\Abstract\Model\Connection ); $this->setMime( - $this::MIME_TEXT_GEMINI + Filesystem::MIME_TEXT_GEMINI ); $this->setCompleted( diff --git a/src/Model/Connection/File.php b/src/Model/Connection/File.php index f22dbd2c..987626dd 100644 --- a/src/Model/Connection/File.php +++ b/src/Model/Connection/File.php @@ -61,7 +61,7 @@ class File } $this->_connection->setMime( - $this->_connection::MIME_TEXT_GEMINI + Filesystem::MIME_TEXT_GEMINI ); $this->_connection->setData( @@ -94,7 +94,7 @@ class File ) ); - if ($this->_connection::MIME_TEXT_PLAIN == $this->_connection->getMime()) + if (Filesystem::MIME_TEXT_PLAIN == $this->_connection->getMime()) { $extension = pathinfo( strval( @@ -106,7 +106,7 @@ class File if (in_array($extension, ['gmi', 'gemini'])) { $this->_connection->setMime( - $this->_connection::MIME_TEXT_GEMINI + Filesystem::MIME_TEXT_GEMINI ); } } diff --git a/src/Model/Connection/Gemini.php b/src/Model/Connection/Gemini.php index fcceea1d..03ace92e 100644 --- a/src/Model/Connection/Gemini.php +++ b/src/Model/Connection/Gemini.php @@ -44,7 +44,7 @@ class Gemini case 11: // sensitive input $this->_connection->setMime( - $this->_connection::MIME_TEXT_GEMINI + Filesystem::MIME_TEXT_GEMINI ); $this->_connection->setRequest( @@ -117,7 +117,7 @@ class Gemini ); $this->_connection->setMime( - $this->_connection::MIME_TEXT_GEMINI + Filesystem::MIME_TEXT_GEMINI ); } diff --git a/src/Model/Connection/Nex.php b/src/Model/Connection/Nex.php index 473dfe39..201c4246 100644 --- a/src/Model/Connection/Nex.php +++ b/src/Model/Connection/Nex.php @@ -8,6 +8,7 @@ use \Yggverse\Net\Address; use \Yggverse\Nex\Client; use \Yggverse\Yoda\Model\Connection; +use \Yggverse\Yoda\Model\Filesystem; class Nex { @@ -43,7 +44,7 @@ class Nex ); $this->_connection->setMime( - $this->_connection::MIME_TEXT_PLAIN + Filesystem::MIME_TEXT_PLAIN ); } @@ -58,7 +59,7 @@ class Nex ); $this->_connection->setMime( - $this->_connection::MIME_TEXT_GEMINI + Filesystem::MIME_TEXT_GEMINI ); } diff --git a/src/Model/Filesystem.php b/src/Model/Filesystem.php index 2f3e294f..b70c840b 100644 --- a/src/Model/Filesystem.php +++ b/src/Model/Filesystem.php @@ -6,6 +6,9 @@ namespace Yggverse\Yoda\Model; class Filesystem { + public const MIME_TEXT_GEMINI = 'text/gemini'; + public const MIME_TEXT_PLAIN = 'text/plain'; + private string $_base; public function __construct(