@@ -2,6 +2,6 @@ |
||
2 | 2 | use \Divergence\App as App; |
3 | 3 | |
4 | 4 | return [ |
5 | - 'debug' => file_exists(App::$ApplicationPath . '/.debug'), |
|
6 | - 'environment' => (file_exists(App::$ApplicationPath . '/.dev') ? 'dev' : 'production'), |
|
5 | + 'debug' => file_exists(App::$ApplicationPath.'/.debug'), |
|
6 | + 'environment' => (file_exists(App::$ApplicationPath.'/.dev') ? 'dev' : 'production'), |
|
7 | 7 | ]; |
@@ -98,7 +98,7 @@ |
||
98 | 98 | |
99 | 99 | // check validator |
100 | 100 | if (!is_callable($validator)) { |
101 | - throw new Exception('Validator for field ' . $options['id'] . ' is not callable'); |
|
101 | + throw new Exception('Validator for field '.$options['id'].' is not callable'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | if ($options['type'] == 'one-one') { |
70 | 70 | if (empty($options['local'])) { |
71 | - $options['local'] = $relationship . 'ID'; |
|
71 | + $options['local'] = $relationship.'ID'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | if (empty($options['foreign'])) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | if (empty($options['foreign'])) { |
83 | - $options['foreign'] = $classShortName. 'ID'; |
|
83 | + $options['foreign'] = $classShortName.'ID'; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | if (!isset($options['indexField'])) { |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | if (empty($options['linkLocal'])) { |
145 | - $options['linkLocal'] = $classShortName . 'ID'; |
|
145 | + $options['linkLocal'] = $classShortName.'ID'; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | if (empty($options['linkForeign'])) { |
149 | 149 | $foreignShortname = basename(str_replace('\\', '/', $options['class']::$rootClass)); |
150 | - $options['linkForeign'] = $foreignShortname . 'ID'; |
|
150 | + $options['linkForeign'] = $foreignShortname.'ID'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | if (empty($options['local'])) { |
@@ -66,7 +66,7 @@ |
||
66 | 66 | ]; |
67 | 67 | |
68 | 68 | if ($options['order']) { |
69 | - $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); |
|
69 | + $query .= ' ORDER BY '.join(',', static::_mapFieldOrder($options['order'])); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if ($options['limit']) { |
@@ -31,8 +31,7 @@ |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | switch ($responseMode ? $responseMode : static::$responseMode) { |
34 | - case 'json': |
|
35 | - JSON::translateAndRespond($responseData); |
|
34 | + case 'json' : JSON::translateAndRespond($responseData); |
|
36 | 35 | break; |
37 | 36 | case 'jsonp': |
38 | 37 | JSONP::translateAndRespond($responseData); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | throw new \Exception(json_last_error_msg()); |
12 | 12 | } |
13 | 13 | header('Content-type: application/javascript; charset=utf-8', true); |
14 | - echo 'var data = ' . $JSON; |
|
14 | + echo 'var data = '.$JSON; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | public static function translateAndRespond($data) |
@@ -20,9 +20,9 @@ |
||
20 | 20 | |
21 | 21 | public static function config($Label) |
22 | 22 | { |
23 | - $Config = static::$ApplicationPath . '/config/' . $Label . '.php'; |
|
23 | + $Config = static::$ApplicationPath.'/config/'.$Label.'.php'; |
|
24 | 24 | if (!file_exists($Config)) { |
25 | - throw new \Exception($Config . ' not found in '.static::class.'::config()'); |
|
25 | + throw new \Exception($Config.' not found in '.static::class.'::config()'); |
|
26 | 26 | } |
27 | 27 | return require $Config; |
28 | 28 | } |
@@ -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']]; |
@@ -414,7 +411,7 @@ discard block |
||
414 | 411 | return static::throwUnauthorizedError(); |
415 | 412 | } |
416 | 413 | |
417 | - if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) { |
|
414 | + if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) { |
|
418 | 415 | if (static::$responseMode == 'json') { |
419 | 416 | $_REQUEST = JSON::getRequestData(); |
420 | 417 | if (is_array($_REQUEST['data'])) { |
@@ -575,7 +572,7 @@ discard block |
||
575 | 572 | |
576 | 573 | public static function getTemplateName($noun) |
577 | 574 | { |
578 | - return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) { |
|
575 | + return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) { |
|
579 | 576 | return strtoupper($matches[1]); |
580 | 577 | }, $noun); |
581 | 578 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @uses self::$Timezone |
103 | 103 | * @uses PDO |
104 | 104 | */ |
105 | - public static function getConnection($label=null) |
|
105 | + public static function getConnection($label = null) |
|
106 | 106 | { |
107 | 107 | if (!$label) { |
108 | 108 | $label = static::getDefaultLabel(); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | |
119 | 119 | if (isset($config['socket'])) { |
120 | 120 | // socket connection |
121 | - $DSN = 'mysql:unix_socket=' . $config['socket'] . ';dbname=' . $config['database']; |
|
121 | + $DSN = 'mysql:unix_socket='.$config['socket'].';dbname='.$config['database']; |
|
122 | 122 | } else { |
123 | 123 | // tcp connection |
124 | - $DSN = 'mysql:host=' . $config['host'] . ';port=' . $config['port'] .';dbname=' . $config['database']; |
|
124 | + $DSN = 'mysql:host='.$config['host'].';port='.$config['port'].';dbname='.$config['database']; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | try { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | if (is_string($data)) { |
151 | 151 | $data = static::getConnection()->quote($data); |
152 | - $data = substr($data, 1, strlen($data)-2); |
|
152 | + $data = substr($data, 1, strlen($data) - 2); |
|
153 | 153 | return $data; |
154 | 154 | } elseif (is_array($data)) { |
155 | 155 | foreach ($data as $key=>$string) { |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | $error = static::getConnection()->errorInfo(); |
489 | 489 | $message = $error[2]; |
490 | 490 | |
491 | - if (App::$Config['environment']=='dev') { |
|
491 | + if (App::$Config['environment'] == 'dev') { |
|
492 | 492 | $Handler = \Divergence\App::$whoops->popHandler(); |
493 | 493 | |
494 | 494 | $Handler->addDataTable("Query Information", [ |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | */ |
534 | 534 | protected static function startQueryLog($query) |
535 | 535 | { |
536 | - if (App::$Config['environment']!='dev') { |
|
536 | + if (App::$Config['environment'] != 'dev') { |
|
537 | 537 | return false; |
538 | 538 | } |
539 | 539 |