Skip to content

Commit ce605ab

Browse files
committed
Rename Json::jsonDecode to Json::decode
1 parent 3edad9c commit ce605ab

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 (!is_array($decodedBody) || !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
@@ -110,23 +110,23 @@ public function managing_subjects_and_versions(): void
110110
->sendAsync(Requests::allSubjectsRequest())
111111
->then(
112112
function (ResponseInterface $request) {
113-
$this->assertEmpty(Json::jsonDecode($request->getBody()->getContents()));
113+
$this->assertEmpty(Json::decode($request->getBody()->getContents()));
114114
}
115115
)->wait();
116116

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

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

131131
$this->assertJsonStringEqualsJsonString($this->baseSchema, $decodedBody['schema']);
132132
}
@@ -136,7 +136,7 @@ function (ResponseInterface $request) {
136136
->sendAsync(Requests::checkIfSubjectHasSchemaRegisteredRequest(self::SUBJECT_NAME, $this->baseSchema))
137137
->then(
138138
function (ResponseInterface $request) {
139-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
139+
$decodedBody = Json::decode($request->getBody()->getContents());
140140

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

154154
$this->assertEquals(self::SUBJECT_NAME, $decodedBody['subject']);
155155
$this->assertEquals(1, $decodedBody['version']);
@@ -165,7 +165,7 @@ function (ResponseInterface $request) {
165165
Constants::VERSION_LATEST
166166
))->then(
167167
function (ResponseInterface $request) {
168-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
168+
$decodedBody = Json::decode($request->getBody()->getContents());
169169

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

251251
$this->client
252252
->sendAsync(Requests::allSubjectVersionsRequest(self::SUBJECT_NAME))
253253
->then(
254254
function (ResponseInterface $request) {
255-
$this->assertEquals([1, 2], Json::jsonDecode($request->getBody()->getContents()));
255+
$this->assertEquals([1, 2], Json::decode($request->getBody()->getContents()));
256256
}
257257
)->wait();
258258
}
@@ -266,7 +266,7 @@ public function managing_compatibility_levels(): void
266266
->sendAsync(Requests::defaultCompatibilityLevelRequest())
267267
->then(
268268
function (ResponseInterface $request) {
269-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
269+
$decodedBody = Json::decode($request->getBody()->getContents());
270270

271271
$this->assertEquals(
272272
Constants::COMPATIBILITY_BACKWARD,
@@ -279,7 +279,7 @@ function (ResponseInterface $request) {
279279
->sendAsync(Requests::changeDefaultCompatibilityLevelRequest(Constants::COMPATIBILITY_FULL))
280280
->then(
281281
function (ResponseInterface $request) {
282-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
282+
$decodedBody = Json::decode($request->getBody()->getContents());
283283

284284
$this->assertEquals(
285285
Constants::COMPATIBILITY_FULL,
@@ -292,7 +292,7 @@ function (ResponseInterface $request) {
292292
->sendAsync(Requests::changeSubjectCompatibilityLevelRequest(self::SUBJECT_NAME, Constants::COMPATIBILITY_FORWARD))
293293
->then(
294294
function (ResponseInterface $request) {
295-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
295+
$decodedBody = Json::decode($request->getBody()->getContents());
296296

297297
$this->assertEquals(
298298
Constants::COMPATIBILITY_FORWARD,
@@ -305,7 +305,7 @@ function (ResponseInterface $request) {
305305
->sendAsync(Requests::subjectCompatibilityLevelRequest(self::SUBJECT_NAME))
306306
->then(
307307
function (ResponseInterface $request) {
308-
$decodedBody = Json::jsonDecode($request->getBody()->getContents());
308+
$decodedBody = Json::decode($request->getBody()->getContents());
309309

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

0 commit comments

Comments
 (0)