diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Diactoros/ServerRequestFactory.php | 26 | ||||
-rw-r--r-- | src/Diactoros/StreamFactory.php | 57 | ||||
-rw-r--r-- | src/Diactoros/UploadedFileFactory.php | 36 | ||||
-rw-r--r--[-rwxr-xr-x] | src/Exception/MetricException.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/Exception/RoadRunnerException.php | 2 | ||||
-rw-r--r-- | src/Exceptions/RoadRunnerException.php | 18 | ||||
-rw-r--r-- | src/HttpClient.php (renamed from src/Http/HttpClient.php) | 0 | ||||
-rw-r--r-- | src/Logger/.empty | 0 | ||||
-rw-r--r-- | src/Metrics.php (renamed from src/Metrics/Metrics.php) | 0 | ||||
-rw-r--r-- | src/MetricsInterface.php (renamed from src/Metrics/MetricsInterface.php) | 0 | ||||
-rw-r--r-- | src/PSR7Client.php (renamed from src/Http/PSR7Client.php) | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/Worker.php | 0 | ||||
-rw-r--r-- | src/WorkerInterface.php | 0 |
13 files changed, 138 insertions, 1 deletions
diff --git a/src/Diactoros/ServerRequestFactory.php b/src/Diactoros/ServerRequestFactory.php new file mode 100644 index 00000000..3fcf8e29 --- /dev/null +++ b/src/Diactoros/ServerRequestFactory.php @@ -0,0 +1,26 @@ +<?php + +/** + * High-performance PHP process supervisor and load balancer written in Go + * + * @author Wolfy-J + */ +declare(strict_types=1); + +namespace Spiral\RoadRunner\Diactoros; + +use Psr\Http\Message\ServerRequestFactoryInterface; +use Psr\Http\Message\ServerRequestInterface; +use Zend\Diactoros\ServerRequest; + +final class ServerRequestFactory implements ServerRequestFactoryInterface +{ + /** + * @inheritdoc + */ + public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface + { + $uploadedFiles = []; + return new ServerRequest($serverParams, $uploadedFiles, $uri, $method); + } +} diff --git a/src/Diactoros/StreamFactory.php b/src/Diactoros/StreamFactory.php new file mode 100644 index 00000000..cc0a5306 --- /dev/null +++ b/src/Diactoros/StreamFactory.php @@ -0,0 +1,57 @@ +<?php + +/** + * High-performance PHP process supervisor and load balancer written in Go + * + * @author Wolfy-J + */ +declare(strict_types=1); + +namespace Spiral\RoadRunner\Diactoros; + +use RuntimeException; +use Psr\Http\Message\StreamFactoryInterface; +use Psr\Http\Message\StreamInterface; +use Zend\Diactoros\Stream; + +final class StreamFactory implements StreamFactoryInterface +{ + /** + * @inheritdoc + * @throws RuntimeException + */ + public function createStream(string $content = ''): StreamInterface + { + $resource = fopen('php://temp', 'rb+'); + + if (! \is_resource($resource)) { + throw new RuntimeException('Cannot create stream'); + } + + fwrite($resource, $content); + rewind($resource); + return $this->createStreamFromResource($resource); + } + + /** + * @inheritdoc + */ + public function createStreamFromFile(string $file, string $mode = 'rb'): StreamInterface + { + $resource = fopen($file, $mode); + + if (! \is_resource($resource)) { + throw new RuntimeException('Cannot create stream'); + } + + return $this->createStreamFromResource($resource); + } + + /** + * @inheritdoc + */ + public function createStreamFromResource($resource): StreamInterface + { + return new Stream($resource); + } +} diff --git a/src/Diactoros/UploadedFileFactory.php b/src/Diactoros/UploadedFileFactory.php new file mode 100644 index 00000000..45773287 --- /dev/null +++ b/src/Diactoros/UploadedFileFactory.php @@ -0,0 +1,36 @@ +<?php + +/** + * High-performance PHP process supervisor and load balancer written in Go + * + * @author Wolfy-J + */ +declare(strict_types=1); + +namespace Spiral\RoadRunner\Diactoros; + +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileFactoryInterface; +use Psr\Http\Message\UploadedFileInterface; +use Zend\Diactoros\UploadedFile; + +final class UploadedFileFactory implements UploadedFileFactoryInterface +{ + /** + * @inheritdoc + */ + public function createUploadedFile( + StreamInterface $stream, + int $size = null, + int $error = \UPLOAD_ERR_OK, + string $clientFilename = null, + string $clientMediaType = null + ): UploadedFileInterface { + if ($size === null) { + $size = (int) $stream->getSize(); + } + + /** @var resource $stream */ + return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType); + } +} diff --git a/src/Exception/MetricException.php b/src/Exception/MetricException.php index d5b738b8..d5b738b8 100755..100644 --- a/src/Exception/MetricException.php +++ b/src/Exception/MetricException.php diff --git a/src/Exception/RoadRunnerException.php b/src/Exception/RoadRunnerException.php index cd657502..f83c3dd4 100755..100644 --- a/src/Exception/RoadRunnerException.php +++ b/src/Exception/RoadRunnerException.php @@ -9,6 +9,6 @@ declare(strict_types=1); namespace Spiral\RoadRunner\Exception; -class RoadRunnerException extends \RuntimeException +class RoadRunnerException extends \Spiral\RoadRunner\Exceptions\RoadRunnerException { } diff --git a/src/Exceptions/RoadRunnerException.php b/src/Exceptions/RoadRunnerException.php new file mode 100644 index 00000000..43967893 --- /dev/null +++ b/src/Exceptions/RoadRunnerException.php @@ -0,0 +1,18 @@ +<?php + +/** + * Spiral Framework. + * + * @license MIT + * @author Anton Titov (Wolfy-J) + */ +declare(strict_types=1); + +namespace Spiral\RoadRunner\Exceptions; + +/** + * @deprecated use \Spiral\RoadRunner\Exception\RoadRunnerException instead + */ +class RoadRunnerException extends \RuntimeException +{ +} diff --git a/src/Http/HttpClient.php b/src/HttpClient.php index 4ca152c8..4ca152c8 100644 --- a/src/Http/HttpClient.php +++ b/src/HttpClient.php diff --git a/src/Logger/.empty b/src/Logger/.empty deleted file mode 100644 index e69de29b..00000000 --- a/src/Logger/.empty +++ /dev/null diff --git a/src/Metrics/Metrics.php b/src/Metrics.php index d6b6e1da..d6b6e1da 100644 --- a/src/Metrics/Metrics.php +++ b/src/Metrics.php diff --git a/src/Metrics/MetricsInterface.php b/src/MetricsInterface.php index ec2009b0..ec2009b0 100644 --- a/src/Metrics/MetricsInterface.php +++ b/src/MetricsInterface.php diff --git a/src/Http/PSR7Client.php b/src/PSR7Client.php index 777dd891..777dd891 100644 --- a/src/Http/PSR7Client.php +++ b/src/PSR7Client.php diff --git a/src/Worker.php b/src/Worker.php index d509562e..d509562e 100755..100644 --- a/src/Worker.php +++ b/src/Worker.php diff --git a/src/WorkerInterface.php b/src/WorkerInterface.php deleted file mode 100644 index e69de29b..00000000 --- a/src/WorkerInterface.php +++ /dev/null |