Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5a6578

Browse files
committed
[Translation] fixed CS
1 parent 9988475 commit c5a6578

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

src/Symfony/Component/Translation/Loader/JsonFileLoader.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ public function load($resource, $locale, $domain = 'messages')
3737

3838
$messages = json_decode(file_get_contents($resource), true);
3939

40-
if (($errorCode = json_last_error()) > 0) {
41-
$message = $this->getJSONErrorMessage($errorCode);
42-
throw new InvalidResourceException(sprintf('Error parsing JSON - %s', $message));
40+
if (0 < $errorCode = json_last_error()) {
41+
throw new InvalidResourceException(sprintf('Error parsing JSON - %s', $this->getJSONErrorMessage($errorCode)));
4342
}
4443

45-
if ($messages === null) {
44+
if (null === $messages) {
4645
$messages = array();
4746
}
4847

@@ -53,35 +52,27 @@ public function load($resource, $locale, $domain = 'messages')
5352
}
5453

5554
/**
56-
* Translates JSON_ERROR_* constant into meaningful message
55+
* Translates JSON_ERROR_* constant into meaningful message.
5756
*
5857
* @param integer $errorCode Error code returned by json_last_error() call
58+
*
5959
* @return string Message string
6060
*/
6161
private function getJSONErrorMessage($errorCode)
6262
{
63-
$errorMsg = null;
6463
switch ($errorCode) {
6564
case JSON_ERROR_DEPTH:
66-
$errorMsg = 'Maximum stack depth exceeded';
67-
break;
65+
return 'Maximum stack depth exceeded';
6866
case JSON_ERROR_STATE_MISMATCH:
69-
$errorMsg = 'Underflow or the modes mismatch';
70-
break;
67+
return 'Underflow or the modes mismatch';
7168
case JSON_ERROR_CTRL_CHAR:
72-
$errorMsg = 'Unexpected control character found';
73-
break;
69+
return 'Unexpected control character found';
7470
case JSON_ERROR_SYNTAX:
75-
$errorMsg = 'Syntax error, malformed JSON';
76-
break;
71+
return 'Syntax error, malformed JSON';
7772
case JSON_ERROR_UTF8:
78-
$errorMsg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
79-
break;
73+
return 'Malformed UTF-8 characters, possibly incorrectly encoded';
8074
default:
81-
$errorMsg = 'Unknown error';
82-
break;
75+
return 'Unknown error';
8376
}
84-
85-
return $errorMsg;
8677
}
8778
}

0 commit comments

Comments
 (0)