File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11MIT License
22
3- Copyright (c) 2020 Radek Ziemniewicz <open-source@quillstack.com>
3+ Copyright (c) 2021 Quillstack
44
55Permission is hereby granted, free of charge, to any person obtaining a copy
66of this software and associated documentation files (the "Software"), to deal
Original file line number Diff line number Diff 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```
Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ version: '3'
22services :
33 php :
44 build : .
5- container_name : quillstack_request
5+ container_name : quillstack_server-request
66 tty : true
77 volumes :
88 - .:/var/www/html
Original file line number Diff line number Diff line change 77use Psr \Http \Message \ServerRequestInterface ;
88use Psr \Http \Message \UriFactoryInterface ;
99use Quillstack \HeaderBag \HeaderBag ;
10+ use Quillstack \HttpRequest \HttpRequest ;
1011use Quillstack \ParameterBag \ParameterBag ;
1112use Quillstack \ServerRequest \Factory \Exceptions \ServerRequestMethodNotKnownException ;
12- use Quillstack \ServerRequest \ServerRequest ;
1313use Quillstack \ServerRequest \Validators \ServerGlobalArrayValidator ;
1414use 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
Original file line number Diff line number Diff line change 88use Psr \Http \Message \StreamInterface ;
99use Psr \Http \Message \UriInterface ;
1010use Quillstack \HeaderBag \HeaderBag ;
11+ use Quillstack \HttpRequest \HttpRequest ;
1112use Quillstack \ServerRequest \Factory \Exceptions \ServerRequestMethodNotKnownException ;
1213use QuillStack \ParameterBag \ParameterBag ;
1314
1415class 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
You can’t perform that action at this time.
0 commit comments