Completed
Pull Request — develop (#28)
by
unknown
01:57
created
src/AjaxController.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@
 block discarded – undo
20 20
 class AjaxController extends Controller
21 21
 {
22 22
 
23
-  /**
24
-   * Contructor
25
-   */
23
+    /**
24
+     * Contructor
25
+     */
26 26
     public function __construct()
27 27
     {
28 28
         $this->_webroot = ERDIKO_ROOT;
Please login to merge, or discard this patch.
src/Logger.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -162,17 +162,17 @@
 block discarded – undo
162 162
      */
163 163
     public function removeLogFile($key)
164 164
     {
165
-         $arrayKey=strtolower($key);
166
-         unset($this->_logFiles[$arrayKey]);
167
-         return true;
165
+            $arrayKey=strtolower($key);
166
+            unset($this->_logFiles[$arrayKey]);
167
+            return true;
168 168
     }
169 169
 
170
-     /**
171
-      * Clear Log
172
-      *
173
-      * @param string $logKey
174
-      * @return bool
175
-      */
170
+        /**
171
+         * Clear Log
172
+         *
173
+         * @param string $logKey
174
+         * @return bool
175
+         */
176 176
     public function clearLog($logKey = null)
177 177
     {
178 178
         $ret=true;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
     public function addRecord($level, $message, array $context = array())
109 109
     {
110 110
         $message = (string) $message;
111
-        $logString=date('Y-m-d H:i:s')." ".$level.": ".$this->interpolate($message, $context).PHP_EOL;
112
-        $logFileName=$this->_logFiles["default"]; // If log key is null use the default log file
111
+        $logString = date('Y-m-d H:i:s')." ".$level.": ".$this->interpolate($message, $context).PHP_EOL;
112
+        $logFileName = $this->_logFiles["default"]; // If log key is null use the default log file
113 113
 
114 114
         return $this->write($logString, $logFileName, null, "a");
115 115
     }
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
         $replace = array();
131 131
         foreach ($context as $key => $val) {
132 132
             if ($key == "exception" && $val instanceof \Exception) {
133
-                $replace['{' . $key . '}'] = $val->getMessage();
133
+                $replace['{'.$key.'}'] = $val->getMessage();
134 134
             } else {
135
-                $replace['{' . $key . '}'] = $val;
135
+                $replace['{'.$key.'}'] = $val;
136 136
             }
137 137
         }
138 138
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function addLogFile($key, $logFileName)
152 152
     {
153
-        $arrayKey=strtolower($key);
153
+        $arrayKey = strtolower($key);
154 154
         return $this->_logFiles[$arrayKey] = $logFileName;
155 155
     }
156 156
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function removeLogFile($key)
164 164
     {
165
-         $arrayKey=strtolower($key);
165
+         $arrayKey = strtolower($key);
166 166
          unset($this->_logFiles[$arrayKey]);
167 167
          return true;
168 168
     }
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
       */
176 176
     public function clearLog($logKey = null)
177 177
     {
178
-        $ret=true;
179
-        if ($logKey==null) {
178
+        $ret = true;
179
+        if ($logKey == null) {
180 180
             foreach ($this->_logFiles as $key => $logFile) {
181 181
                 $ret = $ret && $this->write("", $logFile);
182 182
             }
183 183
             return $ret;
184 184
         } else {
185
-            $arrayKey=strtolower($logKey);
185
+            $arrayKey = strtolower($logKey);
186 186
             if (isset($this->_logFiles[$arrayKey])) {
187 187
                 return $this->write("", $this->_logFiles[$arrayKey]);
188 188
             } else {
Please login to merge, or discard this patch.
Doc Comments   +13 added lines, -12 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      * @param string $level
57 57
      * @param string or an object with a __toString() method$ message
58 58
      * @param array $context
59
-     * @return bool
59
+     * @return integer
60 60
      */
61 61
     public function log($level, $message, array $context = array())
62 62
     {
@@ -92,7 +92,8 @@  discard block
 block discarded – undo
92 92
      * @param string $level
93 93
      * @param string or an object with a __toString() method$ message
94 94
      * @param array $context
95
-     * @return bool
95
+     * @param string $message
96
+     * @return integer
96 97
      */
97 98
     public function addRecord($level, $message, array $context = array())
98 99
     {
@@ -110,7 +111,7 @@  discard block
 block discarded – undo
110 111
      *
111 112
      * @param string $message or an object with a __toString() method
112 113
      * @param array $context replacement values for placeholders
113
-     * @return bool
114
+     * @return string
114 115
      */
115 116
     function interpolate($message, array $context = array())
116 117
     {
@@ -134,7 +135,7 @@  discard block
 block discarded – undo
134 135
      *
135 136
      * @param mixed $key
136 137
      * @param string $logFileName
137
-     * @return bool
138
+     * @return string
138 139
      */
139 140
     public function addLogFile($key, $logFileName)
140 141
     {
@@ -190,7 +191,7 @@  discard block
 block discarded – undo
190 191
      * @param string $message
191 192
      * @param array $context
192 193
      *
193
-     * @return null
194
+     * @return integer
194 195
      */
195 196
     public function emergency($message, array $context = array())
196 197
     {
@@ -207,7 +208,7 @@  discard block
 block discarded – undo
207 208
      * @param string $message
208 209
      * @param array $context
209 210
      *
210
-     * @return null
211
+     * @return integer
211 212
      */
212 213
     public function alert($message, array $context = array())
213 214
     {
@@ -223,7 +224,7 @@  discard block
 block discarded – undo
223 224
      * @param string $message
224 225
      * @param array $context
225 226
      *
226
-     * @return null
227
+     * @return integer
227 228
      */
228 229
     public function critical($message, array $context = array())
229 230
     {
@@ -238,7 +239,7 @@  discard block
 block discarded – undo
238 239
      * @param string $message
239 240
      * @param array $context
240 241
      *
241
-     * @return null
242
+     * @return integer
242 243
      */
243 244
     public function error($message, array $context = array())
244 245
     {
@@ -255,7 +256,7 @@  discard block
 block discarded – undo
255 256
      * @param string $message
256 257
      * @param array $context
257 258
      *
258
-     * @return null
259
+     * @return integer
259 260
      */
260 261
     public function warning($message, array $context = array())
261 262
     {
@@ -269,7 +270,7 @@  discard block
 block discarded – undo
269 270
      * @param string $message
270 271
      * @param array $context
271 272
      *
272
-     * @return null
273
+     * @return integer
273 274
      */
274 275
     public function notice($message, array $context = array())
275 276
     {
@@ -285,7 +286,7 @@  discard block
 block discarded – undo
285 286
      * @param string $message
286 287
      * @param array $context
287 288
      *
288
-     * @return null
289
+     * @return integer
289 290
      */
290 291
     public function info($message, array $context = array())
291 292
     {
@@ -299,7 +300,7 @@  discard block
 block discarded – undo
299 300
      * @param string $message
300 301
      * @param array $context
301 302
      *
302
-     * @return null
303
+     * @return integer
303 304
      */
304 305
     public function debug($message, array $context = array())
305 306
     {
Please login to merge, or discard this patch.
src/Theme.php 4 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     public function addCss($name, $cssFile, $order = 10, $active = 1)
212 212
     {
213
-       $this->_data['css'][$name] = array(
213
+        $this->_data['css'][$name] = array(
214 214
             'file' => $cssFile,
215 215
             'order' => $order,
216 216
             'active' => $active
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
             );
248 248
     }
249 249
 
250
-     /**
251
-     * Get Theme Root Folder
252
-     *
253
-     * @param string $folder
254
-     */
250
+        /**
251
+         * Get Theme Root Folder
252
+         *
253
+         * @param string $folder
254
+         */
255 255
     public function getThemeRootFolder()
256 256
     {
257 257
         return $this->_themeRootFolder;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public function getThemeConfig()
77 77
     {
78 78
         if (empty($this->_themeConfig)) {
79
-            $file = $this->getThemeFolder() . 'theme.json';
79
+            $file = $this->getThemeFolder().'theme.json';
80 80
             $this->_themeConfig = Helper::getConfigFile($file);
81 81
         }
82 82
         return $this->_themeConfig;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     public function getMeta()
91 91
     {
92 92
         if (isset($this->_contextConfig['site']['meta'])) {
93
-            return array_merge($this->_contextConfig['site']['meta'],$this->_data['meta']);
93
+            return array_merge($this->_contextConfig['site']['meta'], $this->_data['meta']);
94 94
         } else {
95 95
             return $this->_data['meta'];
96 96
         }
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
 
128 128
         foreach ($this->getMeta() as $name => $content)
129 129
         {
130
-            if(is_array($content)) {
131
-                foreach($content as $cont)
130
+            if (is_array($content)) {
131
+                foreach ($content as $cont)
132 132
                     $html .= "<meta name=\"{$name}\" content=\"{$cont}\">\n";
133 133
             } else {
134 134
                 $html .= "<meta name=\"{$name}\" content=\"{$content}\">\n";
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,8 +62,9 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function getContextConfig()
64 64
     {
65
-        if (empty($this->_contextConfig))
66
-            $this->_contextConfig = Helper::getConfig('application', $this->_context);
65
+        if (empty($this->_contextConfig)) {
66
+                    $this->_contextConfig = Helper::getConfig('application', $this->_context);
67
+        }
67 68
         
68 69
         return $this->_contextConfig;
69 70
     }
@@ -128,8 +129,9 @@  discard block
 block discarded – undo
128 129
         foreach ($this->getMeta() as $name => $content)
129 130
         {
130 131
             if(is_array($content)) {
131
-                foreach($content as $cont)
132
-                    $html .= "<meta name=\"{$name}\" content=\"{$cont}\">\n";
132
+                foreach($content as $cont) {
133
+                                    $html .= "<meta name=\"{$name}\" content=\"{$cont}\">\n";
134
+                }
133 135
             } else {
134 136
                 $html .= "<meta name=\"{$name}\" content=\"{$content}\">\n";
135 137
             }
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      * @param string $name
207 207
      * @param string $cssFile URL of injected css file
208 208
      * @param int $order 
209
-     * @param boolean $active defaults to 1
209
+     * @param integer $active defaults to 1
210 210
      * @todo need to resolve order of merging and/or eliminate/refactor this function
211 211
      */
212 212
     public function addCss($name, $cssFile, $order = 10, $active = 1)
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      * @param string $name
240 240
      * @param string $jsFile URL of js file
241 241
      * @param int $order 
242
-     * @param boolean $active defaults to 1
242
+     * @param integer $active defaults to 1
243 243
      * @todo same issue as addCss
244 244
      */
245 245
     public function addJs($name, $jsFile, $order = 10, $active = 1)
@@ -254,7 +254,6 @@  discard block
 block discarded – undo
254 254
      /**
255 255
      * Get Theme Root Folder
256 256
      *
257
-     * @param string $folder
258 257
      */
259 258
     public function getThemeRootFolder()
260 259
     {
@@ -295,7 +294,7 @@  discard block
 block discarded – undo
295 294
     /**
296 295
      * Set content
297 296
      *
298
-     * @param string|Container $content any string or object that implements __toString()
297
+     * @param string $content any string or object that implements __toString()
299 298
      */
300 299
     public function setContent($content)
301 300
     {
Please login to merge, or discard this patch.
src/Helper.php 3 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     /**
53 53
      * Read JSON config file and return array
54 54
      *
55
-     * @param string $file
55
+     * @param string $filename
56 56
      * @return array $config
57 57
      */
58 58
     public static function getConfigFile($filename)
@@ -75,6 +75,7 @@  discard block
 block discarded – undo
75 75
     
76 76
     /**
77 77
      * Get configuration
78
+     * @param string $context
78 79
      */
79 80
     public static function getConfig($name = 'application', $context = null)
80 81
     {
@@ -89,6 +90,7 @@  discard block
 block discarded – undo
89 90
      * Get the compiled application routes from the config files
90 91
      *
91 92
      * @todo cache the loaded/compiled routes
93
+     * @param string $context
92 94
      */
93 95
     public static function getRoutes($context = null)
94 96
     {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * Log Object
18 18
      */
19
-    protected static $_logObject=null; // @todo get rid of this
19
+    protected static $_logObject = null; // @todo get rid of this
20 20
 
21 21
     /**
22 22
      * Serve your site
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public static function serve($context = null)
28 28
     {
29
-        if(empty($context))
29
+        if (empty($context))
30 30
             $context = getenv('ERDIKO_CONTEXT');
31 31
         
32 32
         $routes = static::getRoutes($context);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public static function getConfig($name = 'application', $context = null)
80 80
     {
81
-        if($context == null)
81
+        if ($context == null)
82 82
             $context = getenv('ERDIKO_CONTEXT');
83 83
 
84 84
         $filename = ERDIKO_APP."/config/{$context}/{$name}.json";
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public static function getRoutes($context = null)
94 94
     {
95
-        if($context == null)
95
+        if ($context == null)
96 96
             $context = getenv('ERDIKO_CONTEXT');
97 97
         $file = ERDIKO_APP."/config/{$context}/routes.json";
98 98
         $applicationConfig = static::getConfigFile($file);
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public static function sendEmail($toEmail, $subject, $body, $fromEmail)
108 108
     {
109
-        $headers = "From: $fromEmail\r\n" .
110
-            "Reply-To: $fromEmail\r\n" .
111
-            "X-Mailer: PHP/" . phpversion();
109
+        $headers = "From: $fromEmail\r\n".
110
+            "Reply-To: $fromEmail\r\n".
111
+            "X-Mailer: PHP/".phpversion();
112 112
         
113 113
         return mail($toEmail, $subject, $body, $headers);
114 114
     }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public static function log($level, $message, array $context = array())
129 129
     {
130
-        if(static::$_logObject==null)
130
+        if (static::$_logObject == null)
131 131
         {
132 132
             $erdikoContext = getenv('ERDIKO_CONTEXT');
133 133
             $config = static::getConfig("application", $erdikoContext);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
             static::$_logObject = new \erdiko\core\Logger($logFiles, $logDir);
138 138
         }
139 139
 
140
-        if(empty($level))
140
+        if (empty($level))
141 141
             $level = \Psr\Log\LogLevel::DEBUG; // Default to debug for convenience
142 142
 
143 143
         return static::$_logObject->log($level, $message, $context);
Please login to merge, or discard this patch.
Braces   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,8 +26,9 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public static function serve($context = null)
28 28
     {
29
-        if(empty($context))
30
-            $context = getenv('ERDIKO_CONTEXT');
29
+        if(empty($context)) {
30
+                    $context = getenv('ERDIKO_CONTEXT');
31
+        }
31 32
         
32 33
         $routes = static::getRoutes($context);
33 34
         Toro::serve($routes);
@@ -78,8 +79,9 @@  discard block
 block discarded – undo
78 79
      */
79 80
     public static function getConfig($name = 'application', $context = null)
80 81
     {
81
-        if($context == null)
82
-            $context = getenv('ERDIKO_CONTEXT');
82
+        if($context == null) {
83
+                    $context = getenv('ERDIKO_CONTEXT');
84
+        }
83 85
 
84 86
         $filename = ERDIKO_APP."/config/{$context}/{$name}.json";
85 87
         return static::getConfigFile($filename);
@@ -92,8 +94,9 @@  discard block
 block discarded – undo
92 94
      */
93 95
     public static function getRoutes($context = null)
94 96
     {
95
-        if($context == null)
96
-            $context = getenv('ERDIKO_CONTEXT');
97
+        if($context == null) {
98
+                    $context = getenv('ERDIKO_CONTEXT');
99
+        }
97 100
         $file = ERDIKO_APP."/config/{$context}/routes.json";
98 101
         $applicationConfig = static::getConfigFile($file);
99 102
         
@@ -137,8 +140,10 @@  discard block
 block discarded – undo
137 140
             static::$_logObject = new \erdiko\core\Logger($logFiles, $logDir);
138 141
         }
139 142
 
140
-        if(empty($level))
141
-            $level = \Psr\Log\LogLevel::DEBUG; // Default to debug for convenience
143
+        if(empty($level)) {
144
+                    $level = \Psr\Log\LogLevel::DEBUG;
145
+        }
146
+        // Default to debug for convenience
142 147
 
143 148
         return static::$_logObject->log($level, $message, $context);
144 149
     }
Please login to merge, or discard this patch.
src/ToroHook.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -26,6 +26,9 @@
 block discarded – undo
26 26
         $instance->hooks[$hook_name][] = $fn;
27 27
     }
28 28
 
29
+    /**
30
+     * @param string $hook_name
31
+     */
29 32
     public static function fire($hook_name, $params = null)
30 33
     {
31 34
         $instance = static::get_instance();
Please login to merge, or discard this patch.
src/Toro.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             // Search through routes and find first match
50 50
             foreach ($routes as $pattern => $handler_name) {
51 51
                 $patternRep = strtr($pattern, $tokens);
52
-                if (preg_match('#^/?' . $patternRep . '/?$#', $path_info, $matches)) {
52
+                if (preg_match('#^/?'.$patternRep.'/?$#', $path_info, $matches)) {
53 53
                     $discovered_handler = $handler_name;
54 54
                     $regex_matches = $matches;
55 55
                     $params = isset($regex_matches[1]) ? explode("/", $regex_matches[1]) : array();
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
         }
89 89
 
90 90
         if ($handler_instance) {
91
-            if (static::is_xhr_request() && method_exists($handler_instance, $action . '_xhr')) {
91
+            if (static::is_xhr_request() && method_exists($handler_instance, $action.'_xhr')) {
92 92
                 header('Content-type: application/json'); // @todo support xml
93 93
                 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
94
-                header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
94
+                header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
95 95
                 header('Cache-Control: no-store, no-cache, must-revalidate');
96 96
                 header('Cache-Control: post-check=0, pre-check=0', false);
97 97
                 header("Access-Control-Allow-Origin: *"); // @todo make this a parameter?
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
                         $handler_instance->send();
117 117
                     }
118 118
 
119
-                     // render the response and return the data
119
+                        // render the response and return the data
120 120
                     ToroHook::fire(
121 121
                         'after_handler',
122 122
                         compact('routes', 'discovered_handler', 'action', 'arguments', 'result')
Please login to merge, or discard this patch.
src/autoload.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
  * @copyright   2012-2017 Arroyo Labs, Inc. http://www.arroyolabs.com
7 7
  * @author      John Arroyo <[email protected]>
8 8
  */
9
-ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . ERDIKO_ROOT .
10
-    PATH_SEPARATOR . ERDIKO_VENDOR . PATH_SEPARATOR . ERDIKO_APP . PATH_SEPARATOR . ERDIKO_SRC);
9
+ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.ERDIKO_ROOT.
10
+    PATH_SEPARATOR.ERDIKO_VENDOR.PATH_SEPARATOR.ERDIKO_APP.PATH_SEPARATOR.ERDIKO_SRC);
11 11
 
12
-spl_autoload_register(function ($name) {
12
+spl_autoload_register(function($name) {
13 13
 
14 14
     // error_log("autoload: $name");
15 15
 
Please login to merge, or discard this patch.
src/bootstrap.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 require_once ERDIKO_ROOT.'/Erdiko.php';
16 16
 
17 17
 // Set a default context if none specified
18
-if(empty(getenv('ERDIKO_CONTEXT')))
18
+if (empty(getenv('ERDIKO_CONTEXT')))
19 19
         putenv("ERDIKO_CONTEXT=default");
20 20
 
21 21
 $config = \Erdiko::getConfig();
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@
 block discarded – undo
15 15
 require_once ERDIKO_ROOT.'/Erdiko.php';
16 16
 
17 17
 // Set a default context if none specified
18
-if(empty(getenv('ERDIKO_CONTEXT')))
18
+if(empty(getenv('ERDIKO_CONTEXT'))) {
19 19
         putenv("ERDIKO_CONTEXT=default");
20
+}
20 21
 
21 22
 $config = \Erdiko::getConfig();
22 23
 $debug = $config['site']['debug'];
Please login to merge, or discard this patch.