@@ -19,8 +19,7 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @author tony |
| 21 | 21 | */ |
| 22 | -class MyRequestHandler implements RequestHandlerInterface |
|
| 23 | -{ |
|
| 22 | +class MyRequestHandler implements RequestHandlerInterface { |
|
| 24 | 23 | |
| 25 | 24 | public function handle(ServerRequestInterface $request): ResponseInterface |
| 26 | 25 | { |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | |
| 29 | 29 | $name = $param->post('name', 'Tony'); |
| 30 | 30 | $resp = new Response(200); |
| 31 | - $resp->getBody()->write("Hello ${name}"); |
|
| 31 | + $resp->getBody()->write("hello ${name}"); |
|
| 32 | 32 | |
| 33 | 33 | return $resp->withHeader('Framework', 'Platine PHP'); |
| 34 | 34 | } |
@@ -54,8 +54,7 @@ |
||
| 54 | 54 | * classEmitterInterface |
| 55 | 55 | * @package Platine\Framework\Http\Emitter |
| 56 | 56 | */ |
| 57 | -interface EmitterInterface |
|
| 58 | -{ |
|
| 57 | +interface EmitterInterface { |
|
| 59 | 58 | |
| 60 | 59 | /** |
| 61 | 60 | * Emits a HTTP response, that including status line, headers and message |
@@ -40,8 +40,7 @@ |
||
| 40 | 40 | * OutputAlreadySentException |
| 41 | 41 | * @package Platine\Http\Framework\Emitter\Exception |
| 42 | 42 | */ |
| 43 | -class OutputAlreadySentException extends RuntimeException |
|
| 44 | -{ |
|
| 43 | +class OutputAlreadySentException extends RuntimeException { |
|
| 45 | 44 | /** |
| 46 | 45 | * Create new instance |
| 47 | 46 | * @return self |
@@ -40,8 +40,7 @@ |
||
| 40 | 40 | * HeadersAlreadySentException |
| 41 | 41 | * @package Platine\Framework\Http\Emitter\Exception |
| 42 | 42 | */ |
| 43 | -class HeadersAlreadySentException extends RuntimeException |
|
| 44 | -{ |
|
| 43 | +class HeadersAlreadySentException extends RuntimeException { |
|
| 45 | 44 | /** |
| 46 | 45 | * Create new instance |
| 47 | 46 | * @return self |
@@ -58,8 +58,7 @@ discard block |
||
| 58 | 58 | * ResponseEmitter |
| 59 | 59 | * @package Platine\Framework\Http\Emitter |
| 60 | 60 | */ |
| 61 | -class ResponseEmitter implements EmitterInterface |
|
| 62 | -{ |
|
| 61 | +class ResponseEmitter implements EmitterInterface { |
|
| 63 | 62 | |
| 64 | 63 | /** |
| 65 | 64 | * The response before length |
@@ -71,8 +70,7 @@ discard block |
||
| 71 | 70 | * Create new instance |
| 72 | 71 | * @param int|null $bufferLength |
| 73 | 72 | */ |
| 74 | - public function __construct(?int $bufferLength = null) |
|
| 75 | - { |
|
| 73 | + public function __construct(?int $bufferLength = null) { |
|
| 76 | 74 | if ($bufferLength !== null && $bufferLength < 1) { |
| 77 | 75 | throw new InvalidArgumentException(sprintf( |
| 78 | 76 | 'The response buffer length must be greater than zero; received [%d].', |
@@ -37,8 +37,7 @@ |
||
| 37 | 37 | * HttpNotFoundException |
| 38 | 38 | * @package Platine\Framework\Http\Exception |
| 39 | 39 | */ |
| 40 | -class HttpNotFoundException extends HttpSpecialException |
|
| 41 | -{ |
|
| 40 | +class HttpNotFoundException extends HttpSpecialException { |
|
| 42 | 41 | /** |
| 43 | 42 | * The status code |
| 44 | 43 | * @var int |
@@ -40,8 +40,7 @@ |
||
| 40 | 40 | * HttpSpecialException |
| 41 | 41 | * @package Platine\Framework\Http\Exception |
| 42 | 42 | */ |
| 43 | -abstract class HttpSpecialException extends HttpException |
|
| 44 | -{ |
|
| 43 | +abstract class HttpSpecialException extends HttpException { |
|
| 45 | 44 | /** |
| 46 | 45 | * Create new instance |
| 47 | 46 | * @param ServerRequestInterface $request |
@@ -41,8 +41,7 @@ |
||
| 41 | 41 | * HttpException |
| 42 | 42 | * @package Platine\Framework\Http\Exception |
| 43 | 43 | */ |
| 44 | -class HttpException extends Exception |
|
| 45 | -{ |
|
| 44 | +class HttpException extends Exception { |
|
| 46 | 45 | /** |
| 47 | 46 | * The instance of server request that throw this exception |
| 48 | 47 | * @var ServerRequestInterface |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * class RequestData |
| 56 | 56 | * @package Platine\Framework\Http |
| 57 | 57 | */ |
| 58 | -class RequestData |
|
| 59 | -{ |
|
| 58 | +class RequestData { |
|
| 60 | 59 | |
| 61 | 60 | /** |
| 62 | 61 | * The request body or post data |
@@ -86,8 +85,7 @@ discard block |
||
| 86 | 85 | * Create new instance |
| 87 | 86 | * @param ServerRequestInterface $request |
| 88 | 87 | */ |
| 89 | - public function __construct(ServerRequestInterface $request) |
|
| 90 | - { |
|
| 88 | + public function __construct(ServerRequestInterface $request) { |
|
| 91 | 89 | $this->posts = (array) $request->getParsedBody(); |
| 92 | 90 | $this->gets = $request->getQueryParams(); |
| 93 | 91 | $this->servers = $request->getServerParams(); |
@@ -101,8 +99,7 @@ discard block |
||
| 101 | 99 | * |
| 102 | 100 | * @return mixed |
| 103 | 101 | */ |
| 104 | - public function get(string $key, $default = null) |
|
| 105 | - { |
|
| 102 | + public function get(string $key, $default = null) { |
|
| 106 | 103 | return Arr::get($this->gets, $key, $default); |
| 107 | 104 | } |
| 108 | 105 | |
@@ -113,8 +110,7 @@ discard block |
||
| 113 | 110 | * |
| 114 | 111 | * @return mixed |
| 115 | 112 | */ |
| 116 | - public function post(string $key, $default = null) |
|
| 117 | - { |
|
| 113 | + public function post(string $key, $default = null) { |
|
| 118 | 114 | return Arr::get($this->posts, $key, $default); |
| 119 | 115 | } |
| 120 | 116 | |
@@ -125,8 +121,7 @@ discard block |
||
| 125 | 121 | * |
| 126 | 122 | * @return mixed |
| 127 | 123 | */ |
| 128 | - public function server(string $key, $default = null) |
|
| 129 | - { |
|
| 124 | + public function server(string $key, $default = null) { |
|
| 130 | 125 | return Arr::get($this->servers, $key, $default); |
| 131 | 126 | } |
| 132 | 127 | |
@@ -137,8 +132,7 @@ discard block |
||
| 137 | 132 | * |
| 138 | 133 | * @return mixed |
| 139 | 134 | */ |
| 140 | - public function cookie(string $key, $default = null) |
|
| 141 | - { |
|
| 135 | + public function cookie(string $key, $default = null) { |
|
| 142 | 136 | return Arr::get($this->cookies, $key, $default); |
| 143 | 137 | } |
| 144 | 138 | } |