Browse Source

rename buffer to pool

PHP-GTK3
yggverse 4 months ago
parent
commit
4eeb7b3971
  1. 62
      src/Abstract/Model/Connection.php
  2. 4
      src/Interface/Model/Connection.php
  3. 2
      src/Interface/Model/Pool.php

62
src/Abstract/Model/Connection.php

@ -4,54 +4,54 @@ declare(strict_types=1);
namespace Yggverse\Yoda\Abstract\Model; namespace Yggverse\Yoda\Abstract\Model;
use \Yggverse\Yoda\Model\Buffer; use \Yggverse\Yoda\Model\Pool;
abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
{ {
private Buffer $_buffer; private Pool $_pool;
public function __construct( public function __construct(
Buffer $buffer Pool $pool
) { ) {
// Use shared memory for async operations // Use shared memory pool for async operations
$this->_buffer = $buffer; $this->_pool = $pool;
// Set defaults // Set defaults
$this->_buffer->set( $this->_pool->set(
'completed', 'completed',
false false
); );
$this->_buffer->set( $this->_pool->set(
'title', 'title',
null null
); );
$this->_buffer->set( $this->_pool->set(
'subtitle', 'subtitle',
null null
); );
$this->_buffer->set( $this->_pool->set(
'tooltip', 'tooltip',
null null
); );
$this->_buffer->set( $this->_pool->set(
'mime', 'mime',
null null
); );
$this->_buffer->set( $this->_pool->set(
'data', 'data',
null null
); );
$this->_buffer->set( $this->_pool->set(
'redirect', 'redirect',
null null
); );
$this->_buffer->set( $this->_pool->set(
'request', 'request',
null null
); );
@ -59,7 +59,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function isCompleted(): bool public function isCompleted(): bool
{ {
return $this->_buffer->get( return $this->_pool->get(
'completed' 'completed'
); );
} }
@ -68,7 +68,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
bool $completed bool $completed
): void ): void
{ {
$this->_buffer->set( $this->_pool->set(
'completed', 'completed',
$completed $completed
); );
@ -76,7 +76,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getTitle(): ?string public function getTitle(): ?string
{ {
return $this->_buffer->get( return $this->_pool->get(
'title' 'title'
); );
} }
@ -85,7 +85,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
?string $title = null ?string $title = null
): void ): void
{ {
$this->_buffer->set( $this->_pool->set(
'title', 'title',
$title $title
); );
@ -93,7 +93,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getSubtitle(): ?string public function getSubtitle(): ?string
{ {
return $this->_buffer->get( return $this->_pool->get(
'subtitle' 'subtitle'
); );
} }
@ -102,7 +102,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
?string $subtitle = null ?string $subtitle = null
): void ): void
{ {
$this->_buffer->set( $this->_pool->set(
'subtitle', 'subtitle',
$subtitle $subtitle
); );
@ -110,7 +110,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getTooltip(): ?string public function getTooltip(): ?string
{ {
return $this->_buffer->get( return $this->_pool->get(
'tooltip' 'tooltip'
); );
} }
@ -119,7 +119,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
?string $tooltip = null ?string $tooltip = null
): void ): void
{ {
$this->_buffer->set( $this->_pool->set(
'tooltip', 'tooltip',
$tooltip $tooltip
); );
@ -127,7 +127,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getMime(): ?string public function getMime(): ?string
{ {
return $this->_buffer->get( return $this->_pool->get(
'mime' 'mime'
); );
} }
@ -136,7 +136,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
?string $mime = null ?string $mime = null
): void ): void
{ {
$this->_buffer->set( $this->_pool->set(
'mime', 'mime',
$mime $mime
); );
@ -144,7 +144,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getData(): ?string public function getData(): ?string
{ {
return $this->_buffer->get( return $this->_pool->get(
'data' 'data'
); );
} }
@ -153,7 +153,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
?string $data = null ?string $data = null
): void ): void
{ {
$this->_buffer->set( $this->_pool->set(
'data', 'data',
$data $data
); );
@ -161,7 +161,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getRedirect(): ?string public function getRedirect(): ?string
{ {
return $this->_buffer->get( return $this->_pool->get(
'redirect' 'redirect'
); );
} }
@ -170,7 +170,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
?string $redirect = null ?string $redirect = null
): void ): void
{ {
$this->_buffer->set( $this->_pool->set(
'redirect', 'redirect',
$redirect $redirect
); );
@ -178,7 +178,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getRequest(): ?array public function getRequest(): ?array
{ {
return $this->_buffer->get( return $this->_pool->get(
'request' 'request'
); );
} }
@ -188,7 +188,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
bool $visible = true bool $visible = true
): void ): void
{ {
$this->_buffer->set( $this->_pool->set(
'request', 'request',
[ [
'placeholder' => $placeholder, 'placeholder' => $placeholder,
@ -199,7 +199,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function unsetRequest(): void public function unsetRequest(): void
{ {
$this->_buffer->set( $this->_pool->set(
'request', 'request',
null null
); );
@ -208,7 +208,7 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getLength(): ?int public function getLength(): ?int
{ {
return mb_strlen( return mb_strlen(
$this->_buffer->get( $this->_pool->get(
'data' 'data'
) )
); );

4
src/Interface/Model/Connection.php

@ -10,6 +10,10 @@ namespace Yggverse\Yoda\Interface\Model;
*/ */
interface Connection interface Connection
{ {
public function __construct(
\Yggverse\Yoda\Interface\Model\Pool $pool
);
public function request( public function request(
string $request, string $request,
int $timeout = 5 int $timeout = 5

2
src/Interface/Model/Buffer.php → src/Interface/Model/Pool.php

@ -8,7 +8,7 @@ namespace Yggverse\Yoda\Interface\Model;
* Shared memory API for async operations * Shared memory API for async operations
* *
*/ */
interface Buffer interface Pool
{ {
public function get( public function get(
string $key string $key
Loading…
Cancel
Save