generated from Potter/Http-Server-Aware
Initial commit
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
composer.lock
|
||||
composer.phar
|
||||
/nbproject/
|
||||
/vendor/
|
||||
18
LICENSE
Normal file
18
LICENSE
Normal file
@@ -0,0 +1,18 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Jay Potter
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Potter Framework HTTP Server Aware Interface
|
||||
|
||||
Hello World
|
||||
26
composer.json
Normal file
26
composer.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "potter/http-server-aware",
|
||||
"description": "Potter Framework HTTP Server Aware Interface",
|
||||
"version": "1.0.0",
|
||||
"type": "library",
|
||||
"homepage": "https://gitpotter.com/Potter/HTTP-Server-Aware",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jay Potter",
|
||||
"email": "j@ypotter.ca",
|
||||
"homepage": "https://gitpotter.com/"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Potter\\Http\\Server\\": "src/Potter/Http/Server/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"require": {
|
||||
"php": "^8.3",
|
||||
"potter/aware": "^1.0",
|
||||
"react/http": "^1.11"
|
||||
}
|
||||
}
|
||||
16
src/Potter/Http/Server/HttpServerAwareInterface.php
Normal file
16
src/Potter/Http/Server/HttpServerAwareInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?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;
|
||||
}
|
||||
49
src/Potter/Http/Server/HttpServerAwareTrait.php
Normal file
49
src/Potter/Http/Server/HttpServerAwareTrait.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Potter\Http\Server;
|
||||
|
||||
use \React\Http\HttpServer;
|
||||
|
||||
trait HttpServerAwareTrait
|
||||
{
|
||||
private const string HTTP_SERVER = 'httpServer';
|
||||
|
||||
final public function getHttpServer(): HttpServer
|
||||
{
|
||||
return $this->get(self::HTTP_SERVER);
|
||||
}
|
||||
|
||||
final public function hasHttpServer(): bool
|
||||
{
|
||||
return $this->has(self::HTTP_SERVER);
|
||||
}
|
||||
|
||||
final protected function setHttpServer(HttpServer $httpServer): HttpServer
|
||||
{
|
||||
return $this->set(self::HTTP_SERVER, $httpServer);
|
||||
}
|
||||
|
||||
final protected function unsetHttpServer(): null
|
||||
{
|
||||
return $this->unset(self::HTTP_SERVER);
|
||||
}
|
||||
|
||||
final public function withHttpServer(HttpServer $httpServer): static
|
||||
{
|
||||
return $this->with(self::HTTP_SERVER, $httpServer);
|
||||
}
|
||||
|
||||
final public function withoutHttpServer(): static
|
||||
{
|
||||
return $this->without(self::HTTP_SERVER);
|
||||
}
|
||||
|
||||
abstract public function get(string $key): mixed;
|
||||
abstract public function has(string $key): mixed;
|
||||
abstract protected function set(string $key, mixed $value): mixed;
|
||||
abstract protected function unset(string $key): null;
|
||||
abstract public function with(string $key, mixed $value): static;
|
||||
abstract public function without(string $key): static;
|
||||
}
|
||||
Reference in New Issue
Block a user