Skip to content

Commit 0565075

Browse files
committed
namespaced constants
1 parent 40f5065 commit 0565075

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/Http/JsonExceptionResponse.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
namespace Valar\Http;
77

8-
use Mvc5\Arg;
98
use Throwable;
109

10+
use const Mvc5\{ CODE, FILE, HTTP_SERVER_ERROR, LINE, MESSAGE, TRACE };
11+
1112
class JsonExceptionResponse
1213
extends JsonResponse
1314
{
@@ -20,13 +21,13 @@ function __construct(Throwable $exception, bool $trace = false)
2021
{
2122
parent::__construct(
2223
$trace ? [
23-
Arg::CODE => $exception->getCode(),
24-
Arg::MESSAGE => $exception->getMessage(),
25-
Arg::LINE => $exception->getLine(),
26-
Arg::FILE => $exception->getFile(),
27-
Arg::TRACE => $exception->getTrace()
28-
] : [Arg::MESSAGE => ''],
29-
Arg::HTTP_SERVER_ERROR
24+
CODE => $exception->getCode(),
25+
MESSAGE => $exception->getMessage(),
26+
LINE => $exception->getLine(),
27+
FILE => $exception->getFile(),
28+
TRACE => $exception->getTrace()
29+
] : [MESSAGE => ''],
30+
HTTP_SERVER_ERROR
3031
);
3132
}
3233
}

src/Http/JsonResponse.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
namespace Valar\Http;
77

8-
use Mvc5\Arg;
98
use Valar\Stream\JsonStream;
109

10+
use const Mvc5\ { BODY, STATUS, HEADERS };
11+
1112
class JsonResponse
1213
extends Response
1314
{
@@ -20,9 +21,9 @@ class JsonResponse
2021
function __construct($data, $status = 200, array $headers = [])
2122
{
2223
parent::__construct([
23-
Arg::BODY => new JsonStream($data),
24-
Arg::STATUS => $status,
25-
Arg::HEADERS => $headers + ['content-type' => 'application/json']
24+
BODY => new JsonStream($data),
25+
STATUS => $status,
26+
HEADERS => $headers + ['content-type' => 'application/json']
2627
]);
2728
}
2829
}

src/Http/RedirectResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Valar\Http;
77

8-
use Mvc5\Arg;
8+
use const Mvc5\{ HEADERS, STATUS };
99

1010
class RedirectResponse
1111
extends Response
@@ -17,6 +17,6 @@ class RedirectResponse
1717
*/
1818
function __construct($url, $status = 302, array $headers = [])
1919
{
20-
parent::__construct([Arg::STATUS => $status, Arg::HEADERS => $headers + ['location' => (string) $url]]);
20+
parent::__construct([STATUS => $status, HEADERS => $headers + ['location' => (string) $url]]);
2121
}
2222
}

0 commit comments

Comments
 (0)