| @@ -39,13 +39,13 @@ | ||
| 39 | 39 | { |
| 40 | 40 | /** |
| 41 | 41 | * Apache Common Log Format. |
| 42 | 42 | * |
| 43 | - * @see https://httpd.apache.org/docs/2.4/logs.html#common | |
| 43 | + * @link https://httpd.apache.org/docs/2.4/logs.html#common | |
| 44 | 44 | * |
| 45 | 45 | * @var string |
| 46 | 46 | */ |
| 47 | - public const CLF = '{hostname} {req_header_User-Agent} - [{date_common_log}] "{method} {target} HTTP/{version}" {code} {res_header_Content-Length}'; | |
| 47 | + public const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}"; | |
| 48 | 48 | public const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}"; |
| 49 | 49 | public const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}'; |
| 50 | 50 | |
| 51 | 51 | /** |
| @@ -67,9 +67,9 @@ | ||
| 67 | 67 | * @param RequestInterface $request Request that was sent |
| 68 | 68 | * @param ResponseInterface|null $response Response that was received |
| 69 | 69 | * @param \Throwable|null $error Exception that was received |
| 70 | 70 | */ |
| 71 | - public function format(RequestInterface $request, ResponseInterface $response = null, \Throwable $error = null): string | |
| 71 | + public function format(RequestInterface $request, ?ResponseInterface $response = null, ?\Throwable $error = null): string | |
| 72 | 72 | { |
| 73 | 73 | $cache = []; |
| 74 | 74 | |
| 75 | 75 | /** @var string */ |
| @@ -89,11 +89,11 @@ | ||
| 89 | 89 | $result = $response ? Psr7\Message::toString($response) : ''; |
| 90 | 90 | break; |
| 91 | 91 | case 'req_headers': |
| 92 | 92 | $result = \trim($request->getMethod() |
| 93 | - .' '.$request->getRequestTarget()) | |
| 94 | - .' HTTP/'.$request->getProtocolVersion()."\r\n" | |
| 95 | - .$this->headers($request); | |
| 93 | + . ' ' . $request->getRequestTarget()) | |
| 94 | + . ' HTTP/' . $request->getProtocolVersion() . "\r\n" | |
| 95 | + . $this->headers($request); | |
| 96 | 96 | break; |
| 97 | 97 | case 'res_headers': |
| 98 | 98 | $result = $response ? |
| 99 | 99 | \sprintf( |
| @@ -100,9 +100,9 @@ | ||
| 100 | 100 | 'HTTP/%s %d %s', |
| 101 | 101 | $response->getProtocolVersion(), |
| 102 | 102 | $response->getStatusCode(), |
| 103 | 103 | $response->getReasonPhrase() |
| 104 | - )."\r\n".$this->headers($response) | |
| 104 | + ) . "\r\n" . $this->headers($response) | |
| 105 | 105 | : 'NULL'; |
| 106 | 106 | break; |
| 107 | 107 | case 'req_body': |
| 108 | 108 | $result = $request->getBody()->__toString(); |
| @@ -176,9 +176,8 @@ | ||
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | $cache[$matches[1]] = $result; |
| 180 | - | |
| 181 | 180 | return $result; |
| 182 | 181 | }, |
| 183 | 182 | $this->template |
| 184 | 183 | ); |
| @@ -190,9 +189,9 @@ | ||
| 190 | 189 | private function headers(MessageInterface $message): string |
| 191 | 190 | { |
| 192 | 191 | $result = ''; |
| 193 | 192 | foreach ($message->getHeaders() as $name => $values) { |
| 194 | - $result .= $name.': '.\implode(', ', $values)."\r\n"; | |
| 193 | + $result .= $name . ': ' . \implode(', ', $values) . "\r\n"; | |
| 195 | 194 | } |
| 196 | 195 | |
| 197 | 196 | return \trim($result); |
| 198 | 197 | } |