@@ -27,8 +27,9 @@ |
||
| 27 | 27 | if (function_exists('bson_decode')) { |
| 28 | 28 | if ($payload) { |
| 29 | 29 | $bson = bson_decode(trim($payload)); |
| 30 | - if (! $bson) |
|
| 31 | - throw new ParserException('Failed To Parse BSON'); |
|
| 30 | + if (! $bson) { |
|
| 31 | + throw new ParserException('Failed To Parse BSON'); |
|
| 32 | + } |
|
| 32 | 33 | return $bson; |
| 33 | 34 | } |
| 34 | 35 | return array(); |
@@ -27,8 +27,9 @@ |
||
| 27 | 27 | if (function_exists('msgpack_unpack')) { |
| 28 | 28 | if ($payload) { |
| 29 | 29 | $msg = msgpack_unpack(trim($payload)); |
| 30 | - if (! $msg) |
|
| 31 | - throw new ParserException('Failed To Parse MSGPack'); |
|
| 30 | + if (! $msg) { |
|
| 31 | + throw new ParserException('Failed To Parse MSGPack'); |
|
| 32 | + } |
|
| 32 | 33 | return $msg; |
| 33 | 34 | } |
| 34 | 35 | return array(); |
@@ -26,8 +26,9 @@ |
||
| 26 | 26 | { |
| 27 | 27 | if ($payload) { |
| 28 | 28 | $json = json_decode(trim($payload), true); |
| 29 | - if (! $json) |
|
| 30 | - throw new ParserException('Failed To Parse JSON'); |
|
| 29 | + if (! $json) { |
|
| 30 | + throw new ParserException('Failed To Parse JSON'); |
|
| 31 | + } |
|
| 31 | 32 | return $json; |
| 32 | 33 | } |
| 33 | 34 | |
@@ -29,28 +29,28 @@ |
||
| 29 | 29 | * @var array Supported Formats |
| 30 | 30 | */ |
| 31 | 31 | private $supported_formats = array ( |
| 32 | - // XML |
|
| 33 | - 'application/xml' => 'xml', |
|
| 34 | - 'text/xml' => 'xml', |
|
| 35 | - // JSON |
|
| 36 | - 'application/json' => 'json', |
|
| 37 | - 'application/x-javascript' => 'json', |
|
| 38 | - 'text/javascript' => 'json', |
|
| 39 | - 'text/x-javascript' => 'json', |
|
| 40 | - 'text/x-json' => 'json', |
|
| 41 | - // BSON |
|
| 32 | + // XML |
|
| 33 | + 'application/xml' => 'xml', |
|
| 34 | + 'text/xml' => 'xml', |
|
| 35 | + // JSON |
|
| 36 | + 'application/json' => 'json', |
|
| 37 | + 'application/x-javascript' => 'json', |
|
| 38 | + 'text/javascript' => 'json', |
|
| 39 | + 'text/x-javascript' => 'json', |
|
| 40 | + 'text/x-json' => 'json', |
|
| 41 | + // BSON |
|
| 42 | 42 | 'application/bson' => 'bson', |
| 43 | - // YAML |
|
| 44 | - 'text/yaml' => 'yaml', |
|
| 45 | - 'text/x-yaml' => 'yaml', |
|
| 46 | - 'application/yaml' => 'yaml', |
|
| 47 | - 'application/x-yaml' => 'yaml', |
|
| 48 | - // MSGPACK |
|
| 43 | + // YAML |
|
| 44 | + 'text/yaml' => 'yaml', |
|
| 45 | + 'text/x-yaml' => 'yaml', |
|
| 46 | + 'application/yaml' => 'yaml', |
|
| 47 | + 'application/x-yaml' => 'yaml', |
|
| 48 | + // MSGPACK |
|
| 49 | 49 | 'application/msgpack' => 'msgpack', |
| 50 | 50 | 'application/x-msgpack' => 'msgpack', |
| 51 | - // MISC |
|
| 52 | - 'application/vnd.php.serialized' => 'serialize', |
|
| 53 | - 'application/x-www-form-urlencoded' => 'querystr' |
|
| 51 | + // MISC |
|
| 52 | + 'application/vnd.php.serialized' => 'serialize', |
|
| 53 | + 'application/x-www-form-urlencoded' => 'querystr' |
|
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | /* ------------ Access Methods/Helpers ------------ */ |
@@ -107,8 +107,9 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | foreach ($keys as $value) |
| 109 | 109 | { |
| 110 | - if ($this->hasValueAtKey($value, $results) === false) |
|
| 111 | - return false; |
|
| 110 | + if ($this->hasValueAtKey($value, $results) === false) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 112 | 113 | } |
| 113 | 114 | return true; |
| 114 | 115 | } |
@@ -197,13 +198,17 @@ discard block |
||
| 197 | 198 | if (isset($_SERVER['CONTENT_TYPE'])) |
| 198 | 199 | { |
| 199 | 200 | $type = $this->processContentType($_SERVER['CONTENT_TYPE']); |
| 200 | - if ($type !== false) return $type; |
|
| 201 | + if ($type !== false) { |
|
| 202 | + return $type; |
|
| 203 | + } |
|
| 201 | 204 | } |
| 202 | 205 | |
| 203 | 206 | if (isset($_SERVER['HTTP_CONTENT_TYPE'])) |
| 204 | 207 | { |
| 205 | 208 | $type = $this->processContentType($_SERVER['HTTP_CONTENT_TYPE']); |
| 206 | - if ($type !== false) return $type; |
|
| 209 | + if ($type !== false) { |
|
| 210 | + return $type; |
|
| 211 | + } |
|
| 207 | 212 | } |
| 208 | 213 | |
| 209 | 214 | return 'json'; |
@@ -373,8 +378,9 @@ discard block |
||
| 373 | 378 | // Shift the first item of the array |
| 374 | 379 | if (preg_match('/^:(index|item)\[\d+\]$/', $key)) { |
| 375 | 380 | for ($x = substr($key, 7, -1); $x >= 0; $x--) { |
| 376 | - if (empty($data)) |
|
| 377 | - return false; |
|
| 381 | + if (empty($data)) { |
|
| 382 | + return false; |
|
| 383 | + } |
|
| 378 | 384 | $item = array_shift($data); |
| 379 | 385 | } |
| 380 | 386 | } else if ($key == ':last') { |
@@ -385,8 +391,9 @@ discard block |
||
| 385 | 391 | $data =& $item; |
| 386 | 392 | |
| 387 | 393 | } else { |
| 388 | - if (!isset($data[$key]) || !is_array($data[$key])) |
|
| 389 | - return false; |
|
| 394 | + if (!isset($data[$key]) || !is_array($data[$key])) { |
|
| 395 | + return false; |
|
| 396 | + } |
|
| 390 | 397 | |
| 391 | 398 | $data =& $data[$key]; |
| 392 | 399 | } |
@@ -397,8 +404,9 @@ discard block |
||
| 397 | 404 | if (preg_match($this->wildcards, $key)) { |
| 398 | 405 | if (preg_match('/^:(index|item)\[\d+\]$/', $key)) { |
| 399 | 406 | for ($x = substr($key, 7, -1); $x >= 0; $x--) { |
| 400 | - if (empty($data)) |
|
| 401 | - return false; |
|
| 407 | + if (empty($data)) { |
|
| 408 | + return false; |
|
| 409 | + } |
|
| 402 | 410 | $item = array_shift($data); |
| 403 | 411 | } |
| 404 | 412 | return $item; |
@@ -430,8 +438,9 @@ discard block |
||
| 430 | 438 | // Shift the first item of the array |
| 431 | 439 | if (preg_match('/^:(index|item)\[\d+\]$/', $key)) { |
| 432 | 440 | for ($x = substr($key, 7, -1); $x >= 0; $x--) { |
| 433 | - if (empty($data)) |
|
| 434 | - return false; |
|
| 441 | + if (empty($data)) { |
|
| 442 | + return false; |
|
| 443 | + } |
|
| 435 | 444 | $item = array_shift($data); |
| 436 | 445 | } |
| 437 | 446 | } else if ($key == ':last') { |
@@ -442,14 +451,17 @@ discard block |
||
| 442 | 451 | $data =& $item; |
| 443 | 452 | |
| 444 | 453 | } else { |
| 445 | - if (!isset($data[$key])) |
|
| 446 | - return false; |
|
| 454 | + if (!isset($data[$key])) { |
|
| 455 | + return false; |
|
| 456 | + } |
|
| 447 | 457 | |
| 448 | - if (is_bool($data[$key])) |
|
| 449 | - return true; |
|
| 458 | + if (is_bool($data[$key])) { |
|
| 459 | + return true; |
|
| 460 | + } |
|
| 450 | 461 | |
| 451 | - if ($data[$key] === '') |
|
| 452 | - return false; |
|
| 462 | + if ($data[$key] === '') { |
|
| 463 | + return false; |
|
| 464 | + } |
|
| 453 | 465 | |
| 454 | 466 | $data =& $data[$key]; |
| 455 | 467 | } |