Compare commits

..

8 Commits

Author SHA1 Message Date
jay da62588798 de-inherit potter/resource 2026-06-14 12:20:38 -04:00
jay f56cc5d287 description 2026-06-14 12:18:00 -04:00
jay 54323d60c8 add test.php 2026-06-14 12:17:50 -04:00
jay 5f0a0c3a95 0.0.1 2026-06-12 15:41:04 -04:00
jay 40e7bf7898 create StreamFactoryInterface 2026-06-12 14:10:54 -04:00
jay 73e367349f create StreamFactoryInterface 2026-06-12 14:08:45 -04:00
jay 1553d20447 initialize 2026-06-05 15:06:46 -04:00
jay dfa5e83d4d refractor to potter/stream 2026-05-31 17:45:09 -04:00
9 changed files with 96 additions and 6 deletions
+1
View File
@@ -1,4 +1,5 @@
composer.lock composer.lock
composer.phar composer.phar
test.php
/nbproject/ /nbproject/
/vendor/ /vendor/
+2 -2
View File
@@ -1,3 +1,3 @@
# Template # Stream
Potter Framework Component Template Potter Framework Stream Implementation
+13 -4
View File
@@ -1,14 +1,23 @@
{ {
"name": "potter/template", "name": "potter/stream",
"description": "Potter Framework Component Template", "description": "Potter Framework Stream Implementation",
"type": "library", "type": "library",
"require": { "require": {
"php": "^8.5" "php": "^8.5",
"psr/http-factory": "^1.1",
"psr/http-message": "^2.0",
"guzzlehttp/psr7": "^2.11",
"potter/closeable": "^0.0.1",
"potter/detachable": "^0.0.1",
"potter/rewindable": "^0.0.1",
"potter/stringable": "^0.0.1",
"potter/writeable": "^0.0.1",
"potter/readable": "^0.0.1"
}, },
"license": "MIT", "license": "MIT",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Potter\\": "src/Potter/" "Potter\\Stream\\": "src/Potter/Stream/"
} }
}, },
"authors": [ "authors": [
+10
View File
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Potter\Stream;
use \GuzzleHttp\Psr7\Stream as BaseStream;
abstract class AbstractStream extends BaseStream implements StreamInterface
{ }
+11
View File
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace Potter\Stream;
interface SeekableInterface
{
public function isSeekable(): bool;
public function seek(int $offset, int $whence = SEEK_SET): void;
}
+8
View File
@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
namespace Potter\Stream;
final class Stream extends AbstractStream
{ }
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Potter\Stream;
use \Psr\Http\Message\StreamFactoryInterface as BaseStreamFactoryInterface;
use \Psr\Http\Message\StreamInterface as BaseStreamInterface;
interface StreamFactoryInterface extends BaseStreamFactoryInterface
{
public function createStream(string $content = ''): BaseStreamInterface;
public function createStreamFromFile(string $filename, string $mode = 'r'): BaseStreamInterface;
public function createStreamFromResource($resource): BaseStreamInterface;
}
+27
View File
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Potter\Stream;
use \Potter\Stringable\StringableInterface;
use \Potter\Rewindable\RewindableInterface;
use \Potter\Closeable\CloseableInterface;
use \Potter\Detachable\DetachableInterface;
use \Potter\Readable\ReadableInterface;
use \Potter\Writeable\WriteableInterface;
use \Psr\Http\Message\StreamInterface as PsrStreamInterface;
interface StreamInterface extends PsrStreamInterface, StringableInterface,
ReadableInterface, WriteableInterface,
CloseableInterface, DetachableInterface,
RewindableInterface, SeekableInterface
{
public function getSize(): ?int;
public function tell(): int;
public function eof(): bool;
public function getMetadata(?string $key = null);
}
+9
View File
@@ -0,0 +1,9 @@
<?php
require_once __DIR__ . '/vendor/autoload.php';
$server = stream_socket_server("tcp://127.0.0.1:23000",$errno,$errstr);
$stream = new \Potter\Stream\Stream($server);
echo $stream->getContents();