From f2717616686bf02ce244d70f730f19c3b9eacb22 Mon Sep 17 00:00:00 2001 From: yggverse Date: Tue, 16 Jul 2024 12:34:42 +0300 Subject: [PATCH] update Connection::setRequest API --- src/Abstract/Model/Connection.php | 29 +++++++++++++++++++---------- src/Interface/Model/Connection.php | 5 ++++- src/Model/Connection/Gemini.php | 6 ++---- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/Abstract/Model/Connection.php b/src/Abstract/Model/Connection.php index baec4faa..280bf306 100644 --- a/src/Abstract/Model/Connection.php +++ b/src/Abstract/Model/Connection.php @@ -7,16 +7,16 @@ namespace Yggverse\Yoda\Abstract\Model; abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection { // Status - protected bool $_completed = false; + private bool $_completed = false; // Response - protected ?string $_title = null; - protected ?string $_subtitle = null; - protected ?string $_tooltip = null; - protected ?string $_mime = null; - protected ?string $_data = null; - protected ?string $_redirect = null; - protected ?array $_request = null; + private ?string $_title = null; + private ?string $_subtitle = null; + private ?string $_tooltip = null; + private ?string $_mime = null; + private ?string $_data = null; + private ?string $_redirect = null; + private ?array $_request = null; public function isCompleted(): bool { @@ -108,10 +108,19 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection } public function setRequest( - ?array $request = null + ?string $placeholder, + bool $visible = true ): void { - $this->_request = $request; // @TODO + $this->_request = [ + 'placeholder' => $placeholder, + 'visible' => $visible + ]; + } + + public function unsetRequest(): void + { + $this->_request = null; } public function getLength(): ?int diff --git a/src/Interface/Model/Connection.php b/src/Interface/Model/Connection.php index 96100a0a..2712b252 100644 --- a/src/Interface/Model/Connection.php +++ b/src/Interface/Model/Connection.php @@ -63,8 +63,11 @@ interface Connection public function getRequest(): ?array; public function setRequest( - ?array $request = null + ?string $placeholder, + bool $visible = true ): void; + public function unsetRequest(): void; + public function getLength(): ?int; } \ No newline at end of file diff --git a/src/Model/Connection/Gemini.php b/src/Model/Connection/Gemini.php index 9b6eb424..94a6bb78 100644 --- a/src/Model/Connection/Gemini.php +++ b/src/Model/Connection/Gemini.php @@ -47,10 +47,8 @@ class Gemini ); $this->_connection->setRequest( - [ - 'placeholder' => $response->getMeta(), - 'visible' => 11 !== $response->getCode() - ] + $response->getMeta(), + 11 !== $response->getCode() ); break;