Skip to content

Commit 94d7e03

Browse files
more cleanup; add COMMA spelling correction
1 parent c56f790 commit 94d7e03

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

src/Galbar/JsonPath/Expression/Comparison.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public static function evaluate(&$root, &$partial, $leftExpr, $comparator, $righ
3030
}
3131
if ($comparator === Language\Token::COMP_EQ) {
3232
return $left === $right;
33-
} else if ($comparator === Language\Token::COMP_NEQ) {
33+
} elseif ($comparator === Language\Token::COMP_NEQ) {
3434
return $left !== $right;
35-
} else if ($comparator === Language\Token::COMP_LT) {
35+
} elseif ($comparator === Language\Token::COMP_LT) {
3636
return $left < $right;
37-
} else if ($comparator === Language\Token::COMP_GT) {
37+
} elseif ($comparator === Language\Token::COMP_GT) {
3838
return $left > $right;
39-
} else if ($comparator === Language\Token::COMP_LTE) {
39+
} elseif ($comparator === Language\Token::COMP_LTE) {
4040
return $left <= $right;
41-
} else if ($comparator === Language\Token::COMP_GTE) {
41+
} elseif ($comparator === Language\Token::COMP_GTE) {
4242
return $left >= $right;
4343
} else { // $comparator === Language\Token::COMP_RE_MATCH
4444
if (is_string($right) && is_string($left)) {

src/Galbar/JsonPath/Expression/Value.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public static function evaluate(&$root, &$partial, $expression)
2626
{
2727
if ($expression === Language\Token::VAL_NULL) {
2828
return null;
29-
} else if ($expression === Language\Token::VAL_TRUE) {
29+
} elseif ($expression === Language\Token::VAL_TRUE) {
3030
return true;
31-
} else if ($expression === Language\Token::VAL_FALSE) {
31+
} elseif ($expression === Language\Token::VAL_FALSE) {
3232
return false;
33-
} else if (is_numeric($expression)) {
33+
} elseif (is_numeric($expression)) {
3434
return floatval($expression);
35-
} else if (preg_match(Language\Regex::EXPR_STRING, $expression)) {
35+
} elseif (preg_match(Language\Regex::EXPR_STRING, $expression)) {
3636
return substr($expression, 1, strlen($expression) - 2);
37-
} else if (preg_match(Language\Regex::EXPR_REGEX, $expression)) {
37+
} elseif (preg_match(Language\Regex::EXPR_REGEX, $expression)) {
3838
return $expression;
3939
} else {
4040
$match = array();
@@ -54,8 +54,7 @@ public static function evaluate(&$root, &$partial, $expression)
5454
if ($length) {
5555
if (is_array($result[0])) {
5656
return (float) count($result[0]);
57-
}
58-
if (is_string($result[0])) {
57+
} elseif (is_string($result[0])) {
5958
return (float) strlen($result[0]);
6059
}
6160
return false;

src/Galbar/JsonPath/InvalidJsonPathException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ class InvalidJsonPathException extends \Exception
3535
*/
3636
public function __construct($token)
3737
{
38-
parent::__construct("Error in JSONPath near '" . $token . "'", 0, null);
38+
parent::__construct("Error in JSONPath near '{$token}'", 0, null);
3939
}
4040
}

src/Galbar/JsonPath/Language/Token.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Token
2828
const EXPRESSION_END = ')';
2929
const ALL = '*';
3030
const COMA = ',';
31+
const COMMA = ',';
3132
const COLON = ':';
3233
const COMP_EQ = '==';
3334
const COMP_NEQ = '!=';

src/Galbar/JsonPath/Operation/SelectChildren.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function($x) { return intval(trim($x)); },
4949
} else if (preg_match(Language\Regex::CHILD_NAME_LIST, $contents, $match)) {
5050
$names = array_map(
5151
function($x) { return trim($x, " \t\n\r\0\x0B'\""); },
52-
explode(Language\Token::COMA, $contents)
52+
explode(Language\Token::COMMA, $contents)
5353
);
5454
if (count($names) > 1) {
5555
$hasDiverged = true;

src/Galbar/Utilities/ArraySlice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private static function adjustEndpoint($length, $endpoint, $step)
6161
if ($endpoint < 0) {
6262
$endpoint = ($step < 0 ? -1 : 0);
6363
}
64-
} else if ($endpoint >= $length) {
64+
} elseif ($endpoint >= $length) {
6565
$endpoint = ($step < 0 ? $length - 1 : $length);
6666
}
6767
return $endpoint;
@@ -71,7 +71,7 @@ private static function adjustSlice($length, &$start, &$stop, &$step)
7171
{
7272
if ($step === null) {
7373
$step = 1;
74-
} else if ($step === 0) {
74+
} elseif ($step === 0) {
7575
throw new \Exception("Step cannot be 0");
7676
}
7777

0 commit comments

Comments
 (0)