Skip to content

Commit 767f3f0

Browse files
Merge pull request #2 from quillstack/update/http-request
Added library quillstack/http-request
2 parents c2d1803 + a297f4c commit 767f3f0

6 files changed

Lines changed: 9 additions & 55 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

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

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ phpdbg -qrr ./vendor/bin/unit-tests
2626

2727
```shell
2828
$ docker-compose up -d
29-
$ docker exec -w /var/www/html -it quillstack_request sh
29+
$ docker exec -w /var/www/html -it quillstack_server-request sh
3030
```

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"quillstack/parameter-bag": "^0.0.2",
2020
"quillstack/validator-interface": "^0.0.2",
2121
"quillstack/uri": "^0.0.3",
22-
"quillstack/stream": "^0.0.1"
22+
"quillstack/stream": "^0.0.1",
23+
"quillstack/http-request": "^0.0.1"
2324
},
2425
"autoload": {
2526
"psr-4": {

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3'
22
services:
33
php:
44
build: .
5-
container_name: quillstack_request
5+
container_name: quillstack_server-request
66
tty: true
77
volumes:
88
- .:/var/www/html

src/Factory/ServerRequest/ServerRequestFromGlobalsFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use Psr\Http\Message\ServerRequestInterface;
88
use Psr\Http\Message\UriFactoryInterface;
99
use Quillstack\HeaderBag\HeaderBag;
10+
use Quillstack\HttpRequest\HttpRequest;
1011
use Quillstack\ParameterBag\ParameterBag;
1112
use Quillstack\ServerRequest\Factory\Exceptions\ServerRequestMethodNotKnownException;
12-
use Quillstack\ServerRequest\ServerRequest;
1313
use Quillstack\ServerRequest\Validators\ServerGlobalArrayValidator;
1414
use Quillstack\Uri\Uri;
1515

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

90-
if (!in_array($method, ServerRequest::AVAILABLE_METHODS, true)) {
90+
if (!in_array($method, HttpRequest::AVAILABLE_METHODS, true)) {
9191
throw new ServerRequestMethodNotKnownException("Method not known: {$method}");
9292
}
9393

src/ServerRequest.php

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,12 @@
88
use Psr\Http\Message\StreamInterface;
99
use Psr\Http\Message\UriInterface;
1010
use Quillstack\HeaderBag\HeaderBag;
11+
use Quillstack\HttpRequest\HttpRequest;
1112
use Quillstack\ServerRequest\Factory\Exceptions\ServerRequestMethodNotKnownException;
1213
use QuillStack\ParameterBag\ParameterBag;
1314

1415
class ServerRequest implements ServerRequestInterface
1516
{
16-
/**
17-
* @var string
18-
*/
19-
public const METHOD_GET = 'GET';
20-
21-
/**
22-
* @var string
23-
*/
24-
public const METHOD_POST = 'POST';
25-
26-
/**
27-
* @var string
28-
*/
29-
public const METHOD_HEAD = 'HEAD';
30-
31-
/**
32-
* @var string
33-
*/
34-
public const METHOD_PUT = 'PUT';
35-
36-
/**
37-
* @var string
38-
*/
39-
public const METHOD_DELETE = 'DELETE';
40-
41-
/**
42-
* @var string
43-
*/
44-
public const METHOD_PATCH = 'PATCH';
45-
46-
/**
47-
* @var string
48-
*/
49-
public const METHOD_OPTIONS = 'OPTIONS';
50-
51-
/**
52-
* @var array
53-
*/
54-
public const AVAILABLE_METHODS = [
55-
self::METHOD_GET,
56-
self::METHOD_POST,
57-
self::METHOD_HEAD,
58-
self::METHOD_PUT,
59-
self::METHOD_DELETE,
60-
self::METHOD_PATCH,
61-
self::METHOD_OPTIONS,
62-
];
63-
6417
private string $method;
6518
private UriInterface $uri;
6619
private string $protocolVersion;
@@ -269,7 +222,7 @@ public function withMethod($method)
269222
{
270223
$uppercaseMethod = strtoupper($method);
271224

272-
if (!in_array($uppercaseMethod, self::AVAILABLE_METHODS, true)) {
225+
if (!in_array($uppercaseMethod, HttpRequest::AVAILABLE_METHODS, true)) {
273226
throw new ServerRequestMethodNotKnownException("Method not known: {$method}");
274227
}
275228

0 commit comments

Comments
 (0)