@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | if (static::peekPath() == 'json') { |
| 38 | 38 | // check access for API response modes |
| 39 | 39 | static::$responseMode = static::shiftPath(); |
| 40 | - if (in_array(static::$responseMode, ['json','jsonp'])) { |
|
| 40 | + if (in_array(static::$responseMode, ['json', 'jsonp'])) { |
|
| 41 | 41 | if (!static::checkAPIAccess()) { |
| 42 | 42 | return static::throwAPIUnAuthorizedError(); |
| 43 | 43 | } |
@@ -51,8 +51,7 @@ discard block |
||
| 51 | 51 | public static function handleRecordsRequest($action = false) |
| 52 | 52 | { |
| 53 | 53 | switch ($action ? $action : $action = static::shiftPath()) { |
| 54 | - case 'save': |
|
| 55 | - { |
|
| 54 | + case 'save' : { |
|
| 56 | 55 | return static::handleMultiSaveRequest(); |
| 57 | 56 | } |
| 58 | 57 | |
@@ -190,9 +189,7 @@ discard block |
||
| 190 | 189 | } |
| 191 | 190 | |
| 192 | 191 | switch ($action ? $action : $action = static::shiftPath()) { |
| 193 | - case '': |
|
| 194 | - case false: |
|
| 195 | - { |
|
| 192 | + case '' : case false : { |
|
| 196 | 193 | $className = static::$recordClass; |
| 197 | 194 | |
| 198 | 195 | return static::respond(static::getTemplateName($className::$singularNoun), [ |
@@ -280,7 +277,7 @@ discard block |
||
| 280 | 277 | { |
| 281 | 278 | $className = static::$recordClass; |
| 282 | 279 | |
| 283 | - static::prepareResponseModeJSON(['POST','PUT']); |
|
| 280 | + static::prepareResponseModeJSON(['POST', 'PUT']); |
|
| 284 | 281 | |
| 285 | 282 | if ($className::fieldExists(key($_REQUEST['data']))) { |
| 286 | 283 | $_REQUEST['data'] = [$_REQUEST['data']]; |
@@ -352,7 +349,7 @@ discard block |
||
| 352 | 349 | { |
| 353 | 350 | $className = static::$recordClass; |
| 354 | 351 | |
| 355 | - static::prepareResponseModeJSON(['POST','PUT','DELETE']); |
|
| 352 | + static::prepareResponseModeJSON(['POST', 'PUT', 'DELETE']); |
|
| 356 | 353 | |
| 357 | 354 | if ($className::fieldExists(key($_REQUEST['data']))) { |
| 358 | 355 | $_REQUEST['data'] = [$_REQUEST['data']]; |
@@ -374,7 +371,7 @@ discard block |
||
| 374 | 371 | try { |
| 375 | 372 | $results[] = static::processDatumDestroy($datum); |
| 376 | 373 | } |
| 377 | - catch(Exception $e) { |
|
| 374 | + catch (Exception $e) { |
|
| 378 | 375 | $failed[] = [ |
| 379 | 376 | 'record' => $datum, |
| 380 | 377 | 'errors' => $e->getMessage(), |
@@ -415,7 +412,7 @@ discard block |
||
| 415 | 412 | return static::throwUnauthorizedError(); |
| 416 | 413 | } |
| 417 | 414 | |
| 418 | - if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) { |
|
| 415 | + if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) { |
|
| 419 | 416 | if (static::$responseMode == 'json') { |
| 420 | 417 | $_REQUEST = JSON::getRequestData(); |
| 421 | 418 | if (is_array($_REQUEST['data'])) { |
@@ -576,7 +573,7 @@ discard block |
||
| 576 | 573 | |
| 577 | 574 | public static function getTemplateName($noun) |
| 578 | 575 | { |
| 579 | - return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) { |
|
| 576 | + return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) { |
|
| 580 | 577 | return strtoupper($matches[1]); |
| 581 | 578 | }, $noun); |
| 582 | 579 | } |