This commit is contained in:
2026-03-21 11:40:29 -04:00
parent dc88092087
commit 309e270037
4 changed files with 32 additions and 32 deletions

View File

@@ -1,9 +1,9 @@
{
"name": "potter/socket-server-aware",
"description": "Potter Framework HTTP Server Aware Interface",
"description": "Potter Framework Socket Server Aware Interface",
"version": "1.0.0",
"type": "library",
"homepage": "https://gitpotter.com/Potter/HTTP-Server-Aware",
"homepage": "https://gitpotter.com/Potter/Socket-Server-Aware",
"license": "MIT",
"authors": [
{
@@ -14,13 +14,13 @@
],
"autoload": {
"psr-4": {
"Potter\\Http\\Server\\": "src/Potter/Http/Server/"
"Potter\\Socket\\Server\\": "src/Potter/Socket/Server/"
}
},
"minimum-stability": "stable",
"require": {
"php": "^8.3",
"potter/aware": "^1.0",
"react/http": "^1.11"
"react/socket": "^1.17"
}
}

View File

@@ -1,16 +0,0 @@
<?php
declare(strict_types=1);
namespace Potter\Http\Server;
use \Potter\Aware\AwareInterface;
use \React\Http\HttpServer;
interface HttpServerAwareInterface extends AwareInterface
{
public function getHttpServer(): HttpServer;
public function hasHttpServer(): bool;
public function withHttpServer(HttpServer $httpServer): static;
public function withoutHttpServer(): static;
}

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Potter\Socket\Server;
use \Potter\Aware\AwareInterface;
use \React\Socket\SocketServer;
interface SocketServerAwareInterface extends AwareInterface
{
public function getSocketServer(): SocketServer;
public function hasSocketServer(): bool;
public function withSocketServer(SocketServer $socketServer): static;
public function withoutSocketServer(): static;
}

View File

@@ -2,40 +2,40 @@
declare(strict_types=1);
namespace Potter\Http\Server;
namespace Potter\Socket\Server;
use \React\Http\HttpServer;
use \React\Socket\SocketServer;
trait HttpServerAwareTrait
trait SocketServerAwareTrait
{
private const string HTTP_SERVER = 'httpServer';
private const string HTTP_SERVER = 'socketServer';
final public function getHttpServer(): HttpServer
final public function getSocketServer(): SocketServer
{
return $this->get(self::HTTP_SERVER);
}
final public function hasHttpServer(): bool
final public function hasSocketServer(): bool
{
return $this->has(self::HTTP_SERVER);
}
final protected function setHttpServer(HttpServer $httpServer): HttpServer
final protected function setSocketServer(SocketServer $socketServer): SocketServer
{
return $this->set(self::HTTP_SERVER, $httpServer);
return $this->set(self::HTTP_SERVER, $socketServer);
}
final protected function unsetHttpServer(): null
final protected function unsetSocketServer(): null
{
return $this->unset(self::HTTP_SERVER);
}
final public function withHttpServer(HttpServer $httpServer): static
final public function withSocketServer(SocketServer $socketServer): static
{
return $this->with(self::HTTP_SERVER, $httpServer);
return $this->with(self::HTTP_SERVER, $socketServer);
}
final public function withoutHttpServer(): static
final public function withoutSocketServer(): static
{
return $this->without(self::HTTP_SERVER);
}