Skip to content

Commit 3a142c0

Browse files
committed
fixed CS
1 parent a8827ea commit 3a142c0

File tree

3 files changed

+45
-61
lines changed

3 files changed

+45
-61
lines changed

Encoder/JsonDecode.php

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,53 @@
1313

1414
/**
1515
* Decodes JSON data
16-
*
17-
* @author Sander Coolen <[email protected]>
16+
*
17+
* @author Sander Coolen <[email protected]>
1818
*/
1919
class JsonDecode implements DecoderInterface
2020
{
21-
/**
22-
* @var bool
23-
*/
24-
private $associative = false;
25-
/**
26-
* @var int
27-
*/
28-
private $recursionDepth = 512;
29-
/**
30-
* @var int
31-
*/
21+
private $associative;
22+
private $recursionDepth;
3223
private $lastError = JSON_ERROR_NONE;
33-
34-
public function __construct($assoc = false, $depth = 512)
24+
25+
public function __construct($associative = false, $depth = 512)
3526
{
36-
$this->associative = $assoc;
27+
$this->associative = $associative;
3728
$this->recursionDepth = $depth;
3829
}
39-
30+
4031
/**
4132
* Returns the last decoding error (if any)
42-
*
43-
* @return int
33+
*
34+
* @return integer
35+
*
4436
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
4537
*/
4638
public function getLastError()
4739
{
4840
return $this->lastError;
4941
}
50-
42+
5143
/**
5244
* Decodes a JSON string into PHP data
53-
*
45+
*
5446
* @param string $data JSON
55-
* @return mixed
47+
*
48+
* @return mixed
5649
*/
5750
public function decode($data, $format)
5851
{
5952
$decodedData = json_decode($data, $this->associative, $this->recursionDepth);
6053
$this->lastError = json_last_error();
61-
54+
6255
return $decodedData;
6356
}
64-
65-
/**
57+
58+
/**
6659
* {@inheritdoc}
6760
*/
6861
public function supportsDecoding($format)
6962
{
7063
return JsonEncoder::FORMAT === $format;
7164
}
72-
}
65+
}

Encoder/JsonEncode.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,46 @@
1818
*/
1919
class JsonEncode implements EncoderInterface
2020
{
21-
/**
22-
* @var int
23-
*/
24-
private $options = 0;
25-
/**
26-
* @var int
27-
*/
21+
private $options ;
2822
private $lastError = JSON_ERROR_NONE;
29-
23+
3024
public function __construct($bitmask = 0)
3125
{
3226
$this->options = $bitmask;
3327
}
34-
28+
3529
/**
3630
* Returns the last encoding error (if any)
37-
*
38-
* @return int
39-
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
31+
*
32+
* @return integer
33+
*
34+
* @see http://php.net/manual/en/function.json-last-error.php json_last_error
4035
*/
4136
public function getLastError()
4237
{
4338
return $this->lastError;
4439
}
45-
40+
4641
/**
4742
* Encodes PHP data to a JSON string
48-
*
43+
*
4944
* @param mixed $data
50-
* @return string
45+
*
46+
* @return string
5147
*/
5248
public function encode($data, $format)
5349
{
5450
$encodedJson = json_encode($data, $this->options);
5551
$this->lastError = json_last_error();
56-
52+
5753
return $encodedJson;
5854
}
59-
55+
6056
/**
6157
* {@inheritdoc}
6258
*/
6359
public function supportsEncoding($format)
6460
{
6561
return JsonEncoder::FORMAT === $format;
6662
}
67-
}
63+
}

Encoder/JsonEncoder.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,48 +19,43 @@
1919
class JsonEncoder implements EncoderInterface, DecoderInterface
2020
{
2121
const FORMAT = 'json';
22-
22+
2323
/**
2424
* @var JsonEncode
2525
*/
2626
protected $encodingImpl;
27+
2728
/**
2829
* @var JsonDecode
2930
*/
3031
protected $decodingImpl;
3132

3233
public function __construct(JsonEncode $encodingImpl = null, JsonDecode $decodingImpl = null)
3334
{
34-
if (null === $encodingImpl) {
35-
$encodingImpl = new JsonEncode;
36-
}
37-
$this->encodingImpl = $encodingImpl;
38-
if (null === $decodingImpl) {
39-
$decodingImpl = new JsonDecode(true);
40-
}
41-
$this->decodingImpl = $decodingImpl;
35+
$this->encodingImpl = null === $encodingImpl ? new JsonEncode() : $encodingImpl;
36+
$this->decodingImpl = null === $decodingImpl ? new JsonDecode(true) : $decodingImpl;
4237
}
43-
38+
4439
/**
4540
* Returns the last encoding error (if any)
46-
*
47-
* @return int
41+
*
42+
* @return integer
4843
*/
4944
public function getLastEncodingError()
5045
{
5146
return $this->encodingImpl->getLastError();
5247
}
53-
48+
5449
/**
5550
* Returns the last decoding error (if any)
56-
*
57-
* @return int
51+
*
52+
* @return integer
5853
*/
5954
public function getLastDecodingError()
6055
{
6156
return $this->decodingImpl->getLastError();
6257
}
63-
58+
6459
/**
6560
* {@inheritdoc}
6661
*/
@@ -92,4 +87,4 @@ public function supportsDecoding($format)
9287
{
9388
return self::FORMAT === $format;
9489
}
95-
}
90+
}

0 commit comments

Comments
 (0)