Skip to content

Commit 0dac826

Browse files
committed
Rename Json::jsonDecode to Json::decode
1 parent 36a6dba commit 0dac826

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/Exception/ExceptionMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function hasMappableError(ResponseInterface $response): bool
8989
private function guardAgainstMissingErrorCode(ResponseInterface $response): array
9090
{
9191
try {
92-
$decodedBody = Json::jsonDecode((string)$response->getBody());
92+
$decodedBody = Json::decode((string)$response->getBody());
9393

9494
if (!array_key_exists(self::ERROR_CODE_FIELD_NAME, $decodedBody)) {
9595
throw new RuntimeException(

src/Json.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function validateStringAsJson(string $schema): string
3030
*
3131
* @throws JsonException
3232
*/
33-
public static function jsonDecode(string $jsonString, int $depth = 512)
33+
public static function decode(string $jsonString, int $depth = 512)
3434
{
3535
return json_decode($jsonString, true, $depth, JSON_THROW_ON_ERROR);
3636
}
@@ -57,7 +57,7 @@ public static function decodeResponse(ResponseInterface $response): array
5757
$body = (string)$response->getBody();
5858

5959
try {
60-
return Json::jsonDecode($body);
60+
return Json::decode($body);
6161
} catch (JsonException $e) {
6262
throw new InvalidArgumentException(
6363
sprintf('%s - with content "%s"', $e->getMessage(), $body),

src/Requests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function singleSubjectVersionRequest(string $subjectName, string $
4444

4545
public static function prepareJsonSchemaForTransfer(string $schema): string
4646
{
47-
$decoded = Json::jsonDecode($schema);
47+
$decoded = Json::decode($schema);
4848

4949
if (is_array($decoded) && array_key_exists('schema', $decoded)) {
5050
return Json::jsonEncode($decoded);

test/IntegrationTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,23 @@ public function managing_subjects_and_versions(): void
111111
->sendAsync(Requests::allSubjectsRequest())
112112
->then(
113113
function (ResponseInterface $request) {
114-
$this->assertEmpty(Json::jsonDecode($request->getBody()->getContents()));
114+
$this->assertEmpty(Json::decode($request->getBody()->getContents()));
115115
}
116116
)->wait();
117117

118118
$this->client
119119
->sendAsync(Requests::registerNewSchemaVersionWithSubjectRequest($this->baseSchema, self::SUBJECT_NAME))
120120
->then(
121121
function (ResponseInterface $request) {
122-
$this->assertEquals(1, Json::jsonDecode($request->getBody()->getContents())['id']);
122+
$this->assertEquals(1, Json::decode($request->getBody()->getContents())['id']);
123123
}
124124
)->wait();
125125

126126
$this->client
127127
->sendAsync(Requests::schemaRequest('1'))
128128
->then(
129129
function (ResponseInterface $request) {
130-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
130+
$decodedBody = Json::decode($request->getBody()->getContents());
131131

132132
$this->assertJsonStringEqualsJsonString($this->baseSchema, $decodedBody['schema']);
133133
}
@@ -137,7 +137,7 @@ function (ResponseInterface $request) {
137137
->sendAsync(Requests::checkIfSubjectHasSchemaRegisteredRequest(self::SUBJECT_NAME, $this->baseSchema))
138138
->then(
139139
function (ResponseInterface $request) {
140-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
140+
$decodedBody = Json::decode($request->getBody()->getContents());
141141

142142
$this->assertEquals(1, $decodedBody['id']);
143143
$this->assertEquals(1, $decodedBody['version']);
@@ -150,7 +150,7 @@ function (ResponseInterface $request) {
150150
->sendAsync(Requests::singleSubjectVersionRequest(self::SUBJECT_NAME, Constants::VERSION_LATEST))
151151
->then(
152152
function (ResponseInterface $request) {
153-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
153+
$decodedBody = Json::decode($request->getBody()->getContents());
154154

155155
$this->assertEquals(self::SUBJECT_NAME, $decodedBody['subject']);
156156
$this->assertEquals(1, $decodedBody['version']);
@@ -166,7 +166,7 @@ function (ResponseInterface $request) {
166166
Constants::VERSION_LATEST
167167
))->then(
168168
function (ResponseInterface $request) {
169-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
169+
$decodedBody = Json::decode($request->getBody()->getContents());
170170

171171
$this->assertTrue($decodedBody['is_compatible']);
172172
}
@@ -245,15 +245,15 @@ function (RequestException $exception) {
245245
->sendAsync(Requests::registerNewSchemaVersionWithSubjectRequest($this->compatibleSchemaEvolution, self::SUBJECT_NAME))
246246
->then(
247247
function (ResponseInterface $request) {
248-
$this->assertEquals(2, Json::jsonDecode($request->getBody()->getContents())['id']);
248+
$this->assertEquals(2, Json::decode($request->getBody()->getContents())['id']);
249249
}
250250
)->wait();
251251

252252
$this->client
253253
->sendAsync(Requests::allSubjectVersionsRequest(self::SUBJECT_NAME))
254254
->then(
255255
function (ResponseInterface $request) {
256-
$this->assertEquals([1, 2], Json::jsonDecode($request->getBody()->getContents()));
256+
$this->assertEquals([1, 2], Json::decode($request->getBody()->getContents()));
257257
}
258258
)->wait();
259259
}
@@ -267,7 +267,7 @@ public function managing_compatibility_levels(): void
267267
->sendAsync(Requests::defaultCompatibilityLevelRequest())
268268
->then(
269269
function (ResponseInterface $request) {
270-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
270+
$decodedBody = Json::decode($request->getBody()->getContents());
271271

272272
$this->assertEquals(
273273
Constants::COMPATIBILITY_BACKWARD,
@@ -280,7 +280,7 @@ function (ResponseInterface $request) {
280280
->sendAsync(Requests::changeDefaultCompatibilityLevelRequest(Constants::COMPATIBILITY_FULL))
281281
->then(
282282
function (ResponseInterface $request) {
283-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
283+
$decodedBody = Json::decode($request->getBody()->getContents());
284284

285285
$this->assertEquals(
286286
Constants::COMPATIBILITY_FULL,
@@ -293,7 +293,7 @@ function (ResponseInterface $request) {
293293
->sendAsync(Requests::changeSubjectCompatibilityLevelRequest(self::SUBJECT_NAME, Constants::COMPATIBILITY_FORWARD))
294294
->then(
295295
function (ResponseInterface $request) {
296-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
296+
$decodedBody = Json::decode($request->getBody()->getContents());
297297

298298
$this->assertEquals(
299299
Constants::COMPATIBILITY_FORWARD,
@@ -306,7 +306,7 @@ function (ResponseInterface $request) {
306306
->sendAsync(Requests::subjectCompatibilityLevelRequest(self::SUBJECT_NAME))
307307
->then(
308308
function (ResponseInterface $request) {
309-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
309+
$decodedBody = Json::decode($request->getBody()->getContents());
310310

311311
$this->assertEquals(
312312
Constants::COMPATIBILITY_FORWARD,

0 commit comments

Comments
 (0)