Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Radek Ziemniewicz <open-source@quillstack.com>
Copyright (c) 2021 Quillstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ phpdbg -qrr ./vendor/bin/unit-tests

```shell
$ docker-compose up -d
$ docker exec -w /var/www/html -it quillstack_request sh
$ docker exec -w /var/www/html -it quillstack_server-request sh
```
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"quillstack/parameter-bag": "^0.0.2",
"quillstack/validator-interface": "^0.0.2",
"quillstack/uri": "^0.0.3",
"quillstack/stream": "^0.0.1"
"quillstack/stream": "^0.0.1",
"quillstack/http-request": "^0.0.1"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'
services:
php:
build: .
container_name: quillstack_request
container_name: quillstack_server-request
tty: true
volumes:
- .:/var/www/html
4 changes: 2 additions & 2 deletions src/Factory/ServerRequest/ServerRequestFromGlobalsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UriFactoryInterface;
use Quillstack\HeaderBag\HeaderBag;
use Quillstack\HttpRequest\HttpRequest;
use Quillstack\ParameterBag\ParameterBag;
use Quillstack\ServerRequest\Factory\Exceptions\ServerRequestMethodNotKnownException;
use Quillstack\ServerRequest\ServerRequest;
use Quillstack\ServerRequest\Validators\ServerGlobalArrayValidator;
use Quillstack\Uri\Uri;

Expand Down Expand Up @@ -87,7 +87,7 @@ private function getMethod(): string
{
$method = strtoupper($this->server[self::SERVER_REQUEST_METHOD]);

if (!in_array($method, ServerRequest::AVAILABLE_METHODS, true)) {
if (!in_array($method, HttpRequest::AVAILABLE_METHODS, true)) {
throw new ServerRequestMethodNotKnownException("Method not known: {$method}");
}

Expand Down
51 changes: 2 additions & 49 deletions src/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,12 @@
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;
use Quillstack\HeaderBag\HeaderBag;
use Quillstack\HttpRequest\HttpRequest;
use Quillstack\ServerRequest\Factory\Exceptions\ServerRequestMethodNotKnownException;
use QuillStack\ParameterBag\ParameterBag;

class ServerRequest implements ServerRequestInterface
{
/**
* @var string
*/
public const METHOD_GET = 'GET';

/**
* @var string
*/
public const METHOD_POST = 'POST';

/**
* @var string
*/
public const METHOD_HEAD = 'HEAD';

/**
* @var string
*/
public const METHOD_PUT = 'PUT';

/**
* @var string
*/
public const METHOD_DELETE = 'DELETE';

/**
* @var string
*/
public const METHOD_PATCH = 'PATCH';

/**
* @var string
*/
public const METHOD_OPTIONS = 'OPTIONS';

/**
* @var array
*/
public const AVAILABLE_METHODS = [
self::METHOD_GET,
self::METHOD_POST,
self::METHOD_HEAD,
self::METHOD_PUT,
self::METHOD_DELETE,
self::METHOD_PATCH,
self::METHOD_OPTIONS,
];

private string $method;
private UriInterface $uri;
private string $protocolVersion;
Expand Down Expand Up @@ -269,7 +222,7 @@ public function withMethod($method)
{
$uppercaseMethod = strtoupper($method);

if (!in_array($uppercaseMethod, self::AVAILABLE_METHODS, true)) {
if (!in_array($uppercaseMethod, HttpRequest::AVAILABLE_METHODS, true)) {
throw new ServerRequestMethodNotKnownException("Method not known: {$method}");
}

Expand Down