Passed
Pull Request — 1.0.0-dev (#1)
by
unknown
02:46
created
core/classes/Request.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,20 +90,20 @@
 block discarded – undo
90 90
 		/**
91 91
 		 * Construct new request instance
92 92
 		 */
93
-		public function __construct(){
93
+		public function __construct() {
94 94
 			$this->get = $_GET;
95 95
 			$this->post = $_POST;
96 96
 			$this->server = $_SERVER;
97 97
 			$this->query = $_REQUEST;
98 98
 			$this->cookie = $_COOKIE;
99 99
 			$this->file = $_FILES;
100
-			$this->session =& class_loader('Session', 'classes');
100
+			$this->session = & class_loader('Session', 'classes');
101 101
 			$this->method = $this->server('REQUEST_METHOD');
102 102
 			$this->requestUri = $this->server('REQUEST_URI');
103 103
 			$this->header = array();
104
-			if(function_exists('apache_request_headers')){
104
+			if (function_exists('apache_request_headers')) {
105 105
 				$this->header = apache_request_headers();
106
-			} else if(function_exists('getallheaders')){
106
+			} else if (function_exists('getallheaders')) {
107 107
 				$this->header = getallheaders();
108 108
 			}
109 109
 		}
Please login to merge, or discard this patch.
core/classes/BaseClass.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
      */
26 26
 
27
-    class BaseClass{
27
+    class BaseClass {
28 28
         /**
29 29
          * The logger instance
30 30
          * @var object
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         /**
35 35
          * Class constructor
36 36
          */
37
-        public function __construct(){
37
+        public function __construct() {
38 38
             //Set Log instance to use
39 39
                 $this->setLoggerFromParamOrCreate(null);
40 40
         }
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
          *
50 50
          * @return object this current instance
51 51
          */
52
-        protected function setDependencyInstanceFromParamOrCreate($name, $instance = null, $loadClassName = null, $loadClassePath = 'classes'){
53
-            if ($instance !== null){
52
+        protected function setDependencyInstanceFromParamOrCreate($name, $instance = null, $loadClassName = null, $loadClassePath = 'classes') {
53
+            if ($instance !== null) {
54 54
             $this->{$name} = $instance;
55 55
             return $this;
56 56
             }
57
-            $this->{$name} =& class_loader($loadClassName, $loadClassePath);
57
+            $this->{$name} = & class_loader($loadClassName, $loadClassePath);
58 58
             return $this;
59 59
         }
60 60
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
          * Return the Log instance
63 63
          * @return object
64 64
          */
65
-        public function getLogger(){
65
+        public function getLogger() {
66 66
             return $this->logger;
67 67
         }
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
          * @param object $logger the log object
72 72
          * @return object Database
73 73
          */
74
-        public function setLogger($logger){
74
+        public function setLogger($logger) {
75 75
             $this->logger = $logger;
76 76
             return $this;
77 77
         }
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
          *
83 83
          * @return object this current instance
84 84
          */
85
-        protected function setLoggerFromParamOrCreate(Log $logger = null){
85
+        protected function setLoggerFromParamOrCreate(Log $logger = null) {
86 86
             $this->setDependencyInstanceFromParamOrCreate('logger', $logger, 'Log', 'classes');
87
-            if ($logger === null){
87
+            if ($logger === null) {
88 88
             $this->logger->setLogger('Class::' . get_class($this));
89 89
             }
90 90
             return $this;
Please login to merge, or discard this patch.
core/classes/cache/ApcCache.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
      */
26 26
 	
27
-    class ApcCache extends BaseClass implements CacheInterface{
27
+    class ApcCache extends BaseClass implements CacheInterface {
28 28
 
29 29
 		
30 30
 		
31
-        public function __construct(){
31
+        public function __construct() {
32 32
             parent::__construct();
33
-            if(! $this->isSupported()){
33
+            if (!$this->isSupported()) {
34 34
                 show_error('The cache for APC[u] driver is not available. Check if APC[u] extension is loaded and enabled.');
35 35
             }
36 36
         }
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
          * @param  string $key the key to identify the cache data
41 41
          * @return mixed      the cache data if exists else return false
42 42
          */
43
-        public function get($key){
44
-            $this->logger->debug('Getting cache data for key ['. $key .']');
43
+        public function get($key) {
44
+            $this->logger->debug('Getting cache data for key [' . $key . ']');
45 45
             $success = false;
46 46
             $data = apc_fetch($key, $success);
47
-            if($success === false){
48
-                $this->logger->info('No cache found for the key ['. $key .'], return false');
47
+            if ($success === false) {
48
+                $this->logger->info('No cache found for the key [' . $key . '], return false');
49 49
                 return false;
50 50
             }
51
-            else{
51
+            else {
52 52
                 $cacheInfo = $this->_getCacheInfo($key);
53 53
                 $expire = time();
54
-                if($cacheInfo){
54
+                if ($cacheInfo) {
55 55
                     $expire = $cacheInfo['creation_time'] + $cacheInfo['ttl'];
56 56
                 }
57
-                $this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $expire) . ']');
57
+                $this->logger->info('The cache not yet expire, now return the cache data for key [' . $key . '], the cache will expire at [' . date('Y-m-d H:i:s', $expire) . ']');
58 58
                 return $data;
59 59
             }
60 60
         }
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
          * @param integer $ttl  the cache life time
68 68
          * @return boolean true if success otherwise will return false
69 69
          */
70
-        public function set($key, $data, $ttl = 0){
70
+        public function set($key, $data, $ttl = 0) {
71 71
             $expire = time() + $ttl;
72
-            $this->logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
72
+            $this->logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
73 73
             $result = apc_store($key, $data, $ttl);
74
-            if($result === false){
75
-                $this->logger->error('Can not write cache data for the key ['. $key .'], return false');
74
+            if ($result === false) {
75
+                $this->logger->error('Can not write cache data for the key [' . $key . '], return false');
76 76
                 return false;
77 77
             }
78
-            else{
79
-                $this->logger->info('Cache data saved for the key ['. $key .']');
78
+            else {
79
+                $this->logger->info('Cache data saved for the key [' . $key . ']');
80 80
                 return true;
81 81
             }
82 82
         }
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
          * @return boolean      true if the cache is deleted, false if can't delete 
89 89
          * the cache or the cache with the given key not exist
90 90
          */
91
-        public function delete($key){
92
-            $this->logger->debug('Deleting of cache data for key [' .$key. ']');
91
+        public function delete($key) {
92
+            $this->logger->debug('Deleting of cache data for key [' . $key . ']');
93 93
             $cacheInfo = $this->_getCacheInfo($key);
94
-            if($cacheInfo === false){
94
+            if ($cacheInfo === false) {
95 95
                 $this->logger->info('This cache data does not exists skipping');
96 96
                 return false;
97 97
             }
98
-            else{
99
-                $this->logger->info('Found cache data for the key [' .$key. '] remove it');
98
+            else {
99
+                $this->logger->info('Found cache data for the key [' . $key . '] remove it');
100 100
                     return apc_delete($key) === true;
101 101
             }
102 102
         }
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
          * 'expire' => expiration time of the cache (Unix timestamp),
110 110
          * 'ttl' => the time to live of the cache in second
111 111
          */
112
-        public function getInfo($key){
113
-            $this->logger->debug('Getting of cache info for key [' .$key. ']');
112
+        public function getInfo($key) {
113
+            $this->logger->debug('Getting of cache info for key [' . $key . ']');
114 114
             $cacheInfos = $this->_getCacheInfo($key);
115
-            if($cacheInfos){
115
+            if ($cacheInfos) {
116 116
                 $data = array(
117 117
                             'mtime' => $cacheInfos['creation_time'],
118 118
                             'expire' => $cacheInfos['creation_time'] + $cacheInfos['ttl'],
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                             );
121 121
                 return $data;
122 122
             }
123
-            else{
123
+            else {
124 124
                 $this->logger->info('This cache does not exists skipping');
125 125
                 return false;
126 126
             }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         /**
131 131
          * Used to delete expired cache data
132 132
          */
133
-        public function deleteExpiredCache(){
133
+        public function deleteExpiredCache() {
134 134
             //for APC[u] is done automatically
135 135
             return true;
136 136
         }
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
         /**
139 139
          * Remove all cache data
140 140
          */
141
-        public function clean(){
141
+        public function clean() {
142 142
             $this->logger->debug('Deleting of all cache data');
143 143
             $cacheInfos = apc_cache_info('user');
144
-            if(empty($cacheInfos['cache_list'])){
144
+            if (empty($cacheInfos['cache_list'])) {
145 145
                 $this->logger->info('No cache data were found skipping');
146 146
                 return false;
147 147
             }
148
-            else{
148
+            else {
149 149
                 $this->logger->info('Found [' . count($cacheInfos) . '] cache data to remove');
150 150
                 return apc_clear_cache('user');
151 151
             }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
          *
158 158
          * @return bool
159 159
          */
160
-        public function isSupported(){
160
+        public function isSupported() {
161 161
             return (extension_loaded('apc') || extension_loaded('apcu')) && ini_get('apc.enabled');
162 162
         }
163 163
 		
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
          * @param string $key the cache key to get the cache information 
168 168
          * @return boolean|array
169 169
          */
170
-        private function _getCacheInfo($key){
170
+        private function _getCacheInfo($key) {
171 171
             $caches = apc_cache_info('user');
172
-            if(! empty($caches['cache_list'])){
172
+            if (!empty($caches['cache_list'])) {
173 173
                 $cacheLists = $caches['cache_list'];
174
-                foreach ($cacheLists as $c){
175
-                    if(isset($c['info']) && $c['info'] === $key){
174
+                foreach ($cacheLists as $c) {
175
+                    if (isset($c['info']) && $c['info'] === $key) {
176 176
                         return $c;
177 177
                     }
178 178
                 }
Please login to merge, or discard this patch.
core/classes/cache/FileCache.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
      */
26 26
 
27
-    class FileCache extends BaseClass implements CacheInterface{
27
+    class FileCache extends BaseClass implements CacheInterface {
28 28
 		
29 29
         /**
30 30
          * Whether to enable compression of the cache data file.
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
         /**
36 36
          * Class constructor
37 37
          */
38
-        public function __construct(){
38
+        public function __construct() {
39 39
             parent::__construct();
40
-            if(! $this->isSupported()){
40
+            if (!$this->isSupported()) {
41 41
                 show_error('The cache for file system is not available. Check the cache directory if is exists or is writable.');
42 42
             }
43 43
 			
44 44
             //if Zlib extension is not loaded set compressCacheData to false
45
-            if(! extension_loaded('zlib')){
45
+            if (!extension_loaded('zlib')) {
46 46
                 $this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
47 47
                 $this->compressCacheData = false;
48 48
             }
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
          * @param  string $key the key to identify the cache data
54 54
          * @return mixed      the cache data if exists else return false
55 55
          */
56
-        public function get($key){
57
-            $this->logger->debug('Getting cache data for key ['. $key .']');
56
+        public function get($key) {
57
+            $this->logger->debug('Getting cache data for key [' . $key . ']');
58 58
             $filePath = $this->getFilePath($key);
59
-            if(! file_exists($filePath)){
60
-                $this->logger->info('No cache file found for the key ['. $key .'], return false');
59
+            if (!file_exists($filePath)) {
60
+                $this->logger->info('No cache file found for the key [' . $key . '], return false');
61 61
                 return false;
62 62
             }
63
-            $this->logger->info('The cache file [' .$filePath. '] for the key ['. $key .'] exists, check if the cache data is valid');
64
-            $handle = fopen($filePath,'r');
65
-            if(! is_resource($handle)){
66
-                $this->logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
63
+            $this->logger->info('The cache file [' . $filePath . '] for the key [' . $key . '] exists, check if the cache data is valid');
64
+            $handle = fopen($filePath, 'r');
65
+            if (!is_resource($handle)) {
66
+                $this->logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
67 67
                 return false;
68 68
             }
69 69
             // Getting a shared lock 
@@ -71,20 +71,20 @@  discard block
 block discarded – undo
71 71
             $data = file_get_contents($filePath);
72 72
                 fclose($handle);
73 73
                 $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
74
-                if (! $data) {
75
-                    $this->logger->error('Can not unserialize the cache data for the key ['. $key .'], return false');
74
+                if (!$data) {
75
+                    $this->logger->error('Can not unserialize the cache data for the key [' . $key . '], return false');
76 76
                     // If unserializing somehow didn't work out, we'll delete the file
77 77
                     unlink($filePath);
78 78
                     return false;
79 79
                 }
80 80
                 if (time() > $data['expire']) {
81
-                    $this->logger->info('The cache data for the key ['. $key .'] already expired delete the cache file [' .$filePath. ']');
81
+                    $this->logger->info('The cache data for the key [' . $key . '] already expired delete the cache file [' . $filePath . ']');
82 82
                 // Unlinking when the file was expired
83 83
                 unlink($filePath);
84 84
                 return false;
85 85
                 }
86
-                else{
87
-                    $this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
86
+                else {
87
+                    $this->logger->info('The cache not yet expire, now return the cache data for key [' . $key . '], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
88 88
                     return $data['data'];
89 89
                 }
90 90
         }
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
          * @param integer $ttl  the cache life time
98 98
          * @return boolean true if success otherwise will return false
99 99
          */
100
-        public function set($key, $data, $ttl = 0){
100
+        public function set($key, $data, $ttl = 0) {
101 101
             $expire = time() + $ttl;
102
-            $this->logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
102
+            $this->logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
103 103
             $filePath = $this->getFilePath($key);
104
-            $handle = fopen($filePath,'w');
105
-            if(! is_resource($handle)){
106
-                $this->logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
104
+            $handle = fopen($filePath, 'w');
105
+            if (!is_resource($handle)) {
106
+                $this->logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
107 107
                 return false;
108 108
             }
109 109
             flock($handle, LOCK_EX); // exclusive lock, will get released when the file is closed
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
                                     )
117 117
                                 );		   
118 118
             $result = fwrite($handle, $this->compressCacheData ? gzdeflate($cacheData, 9) : $cacheData);
119
-            if(! $result){
120
-                $this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
119
+            if (!$result) {
120
+                $this->logger->error('Can not write cache data into file [' . $filePath . '] for the key [' . $key . '], return false');
121 121
                 fclose($handle);
122 122
                 return false;
123 123
             }
124
-            else{
125
-                $this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
124
+            else {
125
+                $this->logger->info('Cache data saved into file [' . $filePath . '] for the key [' . $key . ']');
126 126
                 fclose($handle);
127 127
                 chmod($filePath, 0640);
128 128
                 return true;
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
          * @return boolean      true if the cache is delete, false if can't delete 
137 137
          * the cache or the cache with the given key not exist
138 138
          */
139
-        public function delete($key){
140
-            $this->logger->debug('Deleting of cache data for key [' .$key. ']');
139
+        public function delete($key) {
140
+            $this->logger->debug('Deleting of cache data for key [' . $key . ']');
141 141
             $filePath = $this->getFilePath($key);
142
-            $this->logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
143
-            if(! file_exists($filePath)){
142
+            $this->logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
143
+            if (!file_exists($filePath)) {
144 144
                 $this->logger->info('This cache file does not exists skipping');
145 145
                 return false;
146 146
             }
147
-            else{
148
-                $this->logger->info('Found cache file [' .$filePath. '] remove it');
147
+            else {
148
+                $this->logger->info('Found cache file [' . $filePath . '] remove it');
149 149
                     unlink($filePath);
150 150
                 return true;
151 151
             }
@@ -159,23 +159,23 @@  discard block
 block discarded – undo
159 159
          * 'expire' => expiration time of the cache (Unix timestamp),
160 160
          * 'ttl' => the time to live of the cache in second
161 161
          */
162
-        public function getInfo($key){
163
-            $this->logger->debug('Getting of cache info for key [' .$key. ']');
162
+        public function getInfo($key) {
163
+            $this->logger->debug('Getting of cache info for key [' . $key . ']');
164 164
             $filePath = $this->getFilePath($key);
165
-            $this->logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
166
-            if(! file_exists($filePath)){
165
+            $this->logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
166
+            if (!file_exists($filePath)) {
167 167
                 $this->logger->info('This cache file does not exists skipping');
168 168
                 return false;
169 169
             }
170
-            $this->logger->info('Found cache file [' .$filePath. '] check the validity');
170
+            $this->logger->info('Found cache file [' . $filePath . '] check the validity');
171 171
                 $data = file_get_contents($filePath);
172 172
             $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
173
-            if(! $data){
173
+            if (!$data) {
174 174
                 $this->logger->warning('Can not unserialize the cache data for file [' . $filePath . ']');
175 175
                 return false;
176 176
             }
177 177
             $this->logger->info('This cache data is OK check for expire');
178
-            if(isset($data['expire']) && $data['expire'] > time()){
178
+            if (isset($data['expire']) && $data['expire'] > time()) {
179 179
                 $this->logger->info('This cache not yet expired return cache informations');
180 180
                 $info = array(
181 181
                     'mtime' => $data['mtime'],
@@ -192,26 +192,26 @@  discard block
 block discarded – undo
192 192
         /**
193 193
          * Used to delete expired cache data
194 194
          */
195
-        public function deleteExpiredCache(){
195
+        public function deleteExpiredCache() {
196 196
             $this->logger->debug('Deleting of expired cache files');
197 197
             $list = glob(CACHE_PATH . '*.cache');
198
-            if(! $list){
198
+            if (!$list) {
199 199
                 $this->logger->info('No cache files were found skipping');
200 200
             }
201
-            else{
201
+            else {
202 202
                 $this->logger->info('Found [' . count($list) . '] cache files to remove if expired');
203 203
                 foreach ($list as $file) {
204 204
                     $this->logger->debug('Processing the cache file [' . $file . ']');
205 205
                     $data = file_get_contents($file);
206 206
                         $data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
207
-                        if(! $data){
207
+                        if (!$data) {
208 208
                             $this->logger->warning('Can not unserialize the cache data for file [' . $file . ']');
209 209
                         }
210
-                        else if(time() > $data['expire']){
210
+                        else if (time() > $data['expire']) {
211 211
                             $this->logger->info('The cache data for file [' . $file . '] already expired remove it');
212 212
                             unlink($file);
213 213
                         }
214
-                        else{
214
+                        else {
215 215
                             $this->logger->info('The cache data for file [' . $file . '] not yet expired skip it');
216 216
                         }
217 217
                 }
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
         /**
222 222
          * Remove all file from cache folder
223 223
          */
224
-        public function clean(){
224
+        public function clean() {
225 225
             $this->logger->debug('Deleting of all cache files');
226 226
             $list = glob(CACHE_PATH . '*.cache');
227
-            if(! $list){
227
+            if (!$list) {
228 228
                 $this->logger->info('No cache files were found skipping');
229 229
             }
230
-            else{
230
+            else {
231 231
                 $this->logger->info('Found [' . count($list) . '] cache files to remove');
232 232
                 foreach ($list as $file) {
233 233
                     $this->logger->debug('Processing the cache file [' . $file . ']');
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
         /**
240 240
          * @return boolean
241 241
          */
242
-        public function isCompressCacheData(){
242
+        public function isCompressCacheData() {
243 243
             return $this->compressCacheData;
244 244
         }
245 245
 
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
          *
249 249
          * @return object
250 250
          */
251
-        public function setCompressCacheData($status = true){
251
+        public function setCompressCacheData($status = true) {
252 252
             //if Zlib extension is not loaded set compressCacheData to false
253
-            if($status === true && ! extension_loaded('zlib')){
253
+            if ($status === true && !extension_loaded('zlib')) {
254 254
 				
255 255
                 $this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
256 256
                 $this->compressCacheData = false;
257 257
             }
258
-            else{
258
+            else {
259 259
                 $this->compressCacheData = $status;
260 260
             }
261 261
             return $this;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
          *
267 267
          * @return bool
268 268
          */
269
-        public function isSupported(){
269
+        public function isSupported() {
270 270
             return CACHE_PATH && is_dir(CACHE_PATH) && is_writable(CACHE_PATH);
271 271
         }
272 272
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
          * @param string $key the cache item key
278 278
          * @return string the full cache file path for this key
279 279
          */
280
-        private function getFilePath($key){
280
+        private function getFilePath($key) {
281 281
             return CACHE_PATH . md5($key) . '.cache';
282 282
         }
283 283
     }
Please login to merge, or discard this patch.
core/classes/Router.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
      */
26 26
 
27
-    class Router extends BaseClass{
27
+    class Router extends BaseClass {
28 28
         /**
29 29
          * @var array $pattern: The list of URIs to validate against
30 30
          */
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
         /**
91 91
          * Construct the new Router instance
92 92
          */
93
-        public function __construct(){
93
+        public function __construct() {
94 94
             parent::__construct();
95 95
 			
96 96
             //loading routes for module
97 97
             $moduleRouteList = array();
98 98
             $modulesRoutes = Module::getModulesRoutesConfig();
99
-            if($modulesRoutes && is_array($modulesRoutes)){
99
+            if ($modulesRoutes && is_array($modulesRoutes)) {
100 100
                 $moduleRouteList = $modulesRoutes;
101 101
                 unset($modulesRoutes);
102 102
             }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
          * Get the route patterns
112 112
          * @return array
113 113
          */
114
-        public function getPattern(){
114
+        public function getPattern() {
115 115
             return $this->pattern;
116 116
         }
117 117
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
          * Get the route callbacks
120 120
          * @return array
121 121
          */
122
-        public function getCallback(){
122
+        public function getCallback() {
123 123
             return $this->callback;
124 124
         }
125 125
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
          * Get the module name
128 128
          * @return string
129 129
          */
130
-        public function getModule(){
130
+        public function getModule() {
131 131
             return $this->module;
132 132
         }
133 133
 		
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
          * Get the controller name
136 136
          * @return string
137 137
          */
138
-        public function getController(){
138
+        public function getController() {
139 139
             return $this->controller;
140 140
         }
141 141
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
          * Get the controller file path
144 144
          * @return string
145 145
          */
146
-        public function getControllerPath(){
146
+        public function getControllerPath() {
147 147
             return $this->controllerPath;
148 148
         }
149 149
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
          * Get the controller method
152 152
          * @return string
153 153
          */
154
-        public function getMethod(){
154
+        public function getMethod() {
155 155
             return $this->method;
156 156
         }
157 157
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
          * Get the request arguments
160 160
          * @return array
161 161
          */
162
-        public function getArgs(){
162
+        public function getArgs() {
163 163
             return $this->args;
164 164
         }
165 165
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
          * Get the URL segments array
168 168
          * @return array
169 169
          */
170
-        public function getSegments(){
170
+        public function getSegments() {
171 171
             return $this->segments;
172 172
         }
173 173
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
          * Get the route URI
176 176
          * @return string
177 177
          */
178
-        public function getRouteUri(){
178
+        public function getRouteUri() {
179 179
             return $this->uri;
180 180
         }
181 181
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
          */
190 190
         public function add($uri, $callback) {
191 191
             $uri = trim($uri, $this->uriTrim);
192
-            if(in_array($uri, $this->pattern)){
192
+            if (in_array($uri, $this->pattern)) {
193 193
                 $this->logger->warning('The route [' . $uri . '] already added, may be adding again can have route conflict');
194 194
             }
195 195
             $this->pattern[] = $uri;
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
          * @return object the current instance
206 206
          */
207 207
         public function removeRoute($uri) {
208
-            $index  = array_search($uri, $this->pattern, true);
209
-            if($index !== false){
208
+            $index = array_search($uri, $this->pattern, true);
209
+            if ($index !== false) {
210 210
                 $this->logger->info('Remove route for uri [' . $uri . '] from the configuration');
211 211
                 unset($this->pattern[$index]);
212 212
                 unset($this->callback[$index]);
@@ -234,26 +234,26 @@  discard block
 block discarded – undo
234 234
          * @param string $uri the route URI, if is empty will determine automatically
235 235
          * @return object
236 236
          */
237
-        public function setRouteUri($uri = ''){
237
+        public function setRouteUri($uri = '') {
238 238
             $routeUri = '';
239
-            if(! empty($uri)){
239
+            if (!empty($uri)) {
240 240
                 $routeUri = $uri;
241 241
             }
242 242
             //if the application is running in CLI mode use the first argument
243
-            else if(IS_CLI && isset($_SERVER['argv'][1])){
243
+            else if (IS_CLI && isset($_SERVER['argv'][1])) {
244 244
                 $routeUri = $_SERVER['argv'][1];
245 245
             }
246
-            else if(isset($_SERVER['REQUEST_URI'])){
246
+            else if (isset($_SERVER['REQUEST_URI'])) {
247 247
                 $routeUri = $_SERVER['REQUEST_URI'];
248 248
             }
249 249
             $this->logger->debug('Check if URL suffix is enabled in the configuration');
250 250
             //remove url suffix from the request URI
251 251
             $suffix = get_config('url_suffix');
252 252
             if ($suffix) {
253
-                $this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']' );
253
+                $this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']');
254 254
                 $routeUri = str_ireplace($suffix, '', $routeUri);
255 255
             } 
256
-            if (strpos($routeUri, '?') !== false){
256
+            if (strpos($routeUri, '?') !== false) {
257 257
                 $routeUri = substr($routeUri, 0, strpos($routeUri, '?'));
258 258
             }
259 259
             $this->uri = trim($routeUri, $this->uriTrim);
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
              * 
267 267
              * @return object
268 268
              */
269
-        public function setRouteSegments(array $segments = array()){
270
-            if(! empty($segments)){
269
+        public function setRouteSegments(array $segments = array()) {
270
+            if (!empty($segments)) {
271 271
                 $this->segments = $segments;
272 272
             } else if (!empty($this->uri)) {
273 273
                 $this->segments = explode('/', $this->uri);
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
             $segment = $this->segments;
276 276
             $baseUrl = get_config('base_url');
277 277
             //check if the app is not in DOCUMENT_ROOT
278
-            if(isset($segment[0]) && stripos($baseUrl, $segment[0]) !== false){
278
+            if (isset($segment[0]) && stripos($baseUrl, $segment[0]) !== false) {
279 279
                 array_shift($segment);
280 280
                 $this->segments = $segment;
281 281
             }
282 282
             $this->logger->debug('Check if the request URI contains the front controller');
283
-            if(isset($segment[0]) && $segment[0] == SELF){
283
+            if (isset($segment[0]) && $segment[0] == SELF) {
284 284
                 $this->logger->info('The request URI contains the front controller');
285 285
                 array_shift($segment);
286 286
                 $this->segments = $segment;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 			
301 301
             //if can not determine the module/controller/method via the defined routes configuration we will use
302 302
             //the URL like http://domain.com/module/controller/method/arg1/arg2
303
-            if(! $this->controller){
303
+            if (!$this->controller) {
304 304
                 $this->logger->info('Cannot determine the routing information using the predefined routes configuration, will use the request URI parameters');
305 305
                 //determine route parameters using the REQUEST_URI param
306 306
                 $this->determineRouteParamsFromRequestUri();
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
              * Routing the request to the correspondant module/controller/method if exists
317 317
              * otherwise send 404 error.
318 318
              */
319
-        public function processRequest(){
319
+        public function processRequest() {
320 320
             //Setting the route URI
321 321
             $this->setRouteUri();
322 322
 
323 323
             //setting route segments
324 324
             $this->setRouteSegments();
325 325
 
326
-            $this->logger->info('The final Request URI is [' . implode('/', $this->segments) . ']' );
326
+            $this->logger->info('The final Request URI is [' . implode('/', $this->segments) . ']');
327 327
 
328 328
             //determine the route parameters information
329 329
             $this->determineRouteParamsInformation();
@@ -334,20 +334,20 @@  discard block
 block discarded – undo
334 334
             $this->logger->info('The routing information are: module [' . $this->module . '], controller [' . $controller . '], method [' . $this->method . '], args [' . stringfy_vars($this->args) . ']');
335 335
             $this->logger->debug('Loading controller [' . $controller . '], the file path is [' . $classFilePath . ']...');
336 336
 	    	
337
-            if(file_exists($classFilePath)){
337
+            if (file_exists($classFilePath)) {
338 338
                 require_once $classFilePath;
339
-                if(! class_exists($controller, false)){
339
+                if (!class_exists($controller, false)) {
340 340
                     $e404 = true;
341
-                    $this->logger->warning('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']');
341
+                    $this->logger->warning('The controller file [' . $classFilePath . '] exists but does not contain the class [' . $controller . ']');
342 342
                 }
343
-                else{
343
+                else {
344 344
                     $controllerInstance = new $controller();
345 345
                     $controllerMethod = $this->getMethod();
346
-                    if(! method_exists($controllerInstance, $controllerMethod)){
346
+                    if (!method_exists($controllerInstance, $controllerMethod)) {
347 347
                         $e404 = true;
348 348
                         $this->logger->warning('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']');
349 349
                     }
350
-                    else{
350
+                    else {
351 351
                         $this->logger->info('Routing data is set correctly now GO!');
352 352
                         call_user_func_array(array($controllerInstance, $controllerMethod), $this->args);
353 353
                         //render the final page to user
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
                     }
357 357
                 }
358 358
             }
359
-            else{
359
+            else {
360 360
                 $this->logger->info('The controller file path [' . $classFilePath . '] does not exist');
361 361
                 $e404 = true;
362 362
             }
363
-            if($e404){
364
-                if(IS_CLI){
363
+            if ($e404) {
364
+                if (IS_CLI) {
365 365
                     set_http_status_header(404);
366 366
                     echo 'Error 404: page not found.';
367 367
                 } else {
368
-                    $response =& class_loader('Response', 'classes');
368
+                    $response = & class_loader('Response', 'classes');
369 369
                     $response->send404();
370 370
                 }
371 371
             }
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
          * @param boolean $useConfigFile whether to use route configuration file
379 379
          * @return object
380 380
          */
381
-        public function setRouteConfiguration(array $overwriteConfig = array(), $useConfigFile = true){
381
+        public function setRouteConfiguration(array $overwriteConfig = array(), $useConfigFile = true) {
382 382
             $route = array();
383
-            if ($useConfigFile && file_exists(CONFIG_PATH . 'routes.php')){
383
+            if ($useConfigFile && file_exists(CONFIG_PATH . 'routes.php')) {
384 384
                 require_once CONFIG_PATH . 'routes.php';
385 385
             }
386 386
             $route = array_merge($route, $overwriteConfig);
387 387
             $this->routes = $route;
388 388
             //if route is empty remove all configuration
389
-            if(empty($route)){
389
+            if (empty($route)) {
390 390
                 $this->removeAllRoute();
391 391
             }
392 392
             return $this;
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
              * Get the route configuration
397 397
              * @return array
398 398
              */
399
-        public function getRouteConfiguration(){
399
+        public function getRouteConfiguration() {
400 400
             return $this->routes;
401 401
         }
402 402
 
@@ -408,19 +408,19 @@  discard block
 block discarded – undo
408 408
          *
409 409
          * @return object the current instance
410 410
          */
411
-        public function setControllerFilePath($path = null){
412
-            if($path !== null){
411
+        public function setControllerFilePath($path = null) {
412
+            if ($path !== null) {
413 413
                 $this->controllerPath = $path;
414 414
                 return $this;
415 415
             }
416 416
             //did we set the controller, so set the controller path
417
-            if($this->controller && ! $this->controllerPath){
417
+            if ($this->controller && !$this->controllerPath) {
418 418
                 $this->logger->debug('Setting the file path for the controller [' . $this->controller . ']');
419 419
                 $controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->controller) . '.php';
420 420
                 //if the controller is in module
421
-                if($this->module){
421
+                if ($this->module) {
422 422
                     $path = Module::findControllerFullPath(ucfirst($this->controller), $this->module);
423
-                    if($path !== false){
423
+                    if ($path !== false) {
424 424
                         $controllerPath = $path;
425 425
                     }
426 426
                 }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
          * Determine the route parameters from route configuration
434 434
          * @return void
435 435
          */
436
-        protected function determineRouteParamsFromConfig(){
436
+        protected function determineRouteParamsFromConfig() {
437 437
             $uri = implode('/', $this->segments);
438 438
             /*
439 439
 	   		* Generics routes patterns
@@ -458,20 +458,20 @@  discard block
 block discarded – undo
458 458
                     array_shift($args);
459 459
                     //check if this contains an module
460 460
                     $moduleControllerMethod = explode('#', $this->callback[$index]);
461
-                    if(is_array($moduleControllerMethod) && count($moduleControllerMethod) >= 2){
461
+                    if (is_array($moduleControllerMethod) && count($moduleControllerMethod) >= 2) {
462 462
                         $this->logger->info('The current request use the module [' . $moduleControllerMethod[0] . ']');
463 463
                         $this->module = $moduleControllerMethod[0];
464 464
                         $moduleControllerMethod = explode('@', $moduleControllerMethod[1]);
465 465
                     }
466
-                    else{
466
+                    else {
467 467
                         $this->logger->info('The current request does not use the module');
468 468
                         $moduleControllerMethod = explode('@', $this->callback[$index]);
469 469
                     }
470
-                    if(is_array($moduleControllerMethod)){
471
-                        if(isset($moduleControllerMethod[0])){
470
+                    if (is_array($moduleControllerMethod)) {
471
+                        if (isset($moduleControllerMethod[0])) {
472 472
                             $this->controller = $moduleControllerMethod[0];	
473 473
                         }
474
-                        if(isset($moduleControllerMethod[1])){
474
+                        if (isset($moduleControllerMethod[1])) {
475 475
                             $this->method = $moduleControllerMethod[1];
476 476
                         }
477 477
                         $this->args = $args;
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
             }
483 483
 
484 484
             //first if the controller is not set and the module is set use the module name as the controller
485
-            if(! $this->controller && $this->module){
485
+            if (!$this->controller && $this->module) {
486 486
                 $this->logger->info(
487 487
                                     'After loop in predefined routes configuration, 
488 488
 									the module name is set but the controller is not set, 
@@ -496,67 +496,67 @@  discard block
 block discarded – undo
496 496
          * Determine the route parameters using the server variable "REQUEST_URI"
497 497
          * @return void
498 498
          */
499
-        protected function determineRouteParamsFromRequestUri(){
499
+        protected function determineRouteParamsFromRequestUri() {
500 500
             $segment = $this->segments;
501 501
             $nbSegment = count($segment);
502 502
             //if segment is null so means no need to perform
503
-            if($nbSegment > 0){
503
+            if ($nbSegment > 0) {
504 504
                 //get the module list
505 505
                 $modules = Module::getModuleList();
506 506
                 //first check if no module
507
-                if(empty($modules)){
507
+                if (empty($modules)) {
508 508
                     $this->logger->info('No module was loaded will skip the module checking');
509 509
                     //the application don't use module
510 510
                     //controller
511
-                    if(isset($segment[0])){
511
+                    if (isset($segment[0])) {
512 512
                         $this->controller = $segment[0];
513 513
                         array_shift($segment);
514 514
                     }
515 515
                     //method
516
-                    if(isset($segment[0])){
516
+                    if (isset($segment[0])) {
517 517
                         $this->method = $segment[0];
518 518
                         array_shift($segment);
519 519
                     }
520 520
                     //args
521 521
                     $this->args = $segment;
522 522
                 }
523
-                else{
523
+                else {
524 524
                     $this->logger->info('The application contains a loaded module will check if the current request is found in the module list');
525
-                    if(in_array($segment[0], $modules)){
525
+                    if (in_array($segment[0], $modules)) {
526 526
                         $this->logger->info('Found, the current request use the module [' . $segment[0] . ']');
527 527
                         $this->module = $segment[0];
528 528
                         array_shift($segment);
529 529
                         //check if the second arg is the controller from module
530
-                        if(isset($segment[0])){
530
+                        if (isset($segment[0])) {
531 531
                             $this->controller = $segment[0];
532 532
                             //check if the request use the same module name and controller
533 533
                             $path = Module::findControllerFullPath(ucfirst($this->controller), $this->module);
534
-                            if(! $path){
534
+                            if (!$path) {
535 535
                                 $this->logger->info('The controller [' . $this->controller . '] not found in the module, may be will use the module [' . $this->module . '] as controller');
536 536
                                 $this->controller = $this->module;
537 537
                             }
538
-                            else{
538
+                            else {
539 539
                                 $this->controllerPath = $path;
540 540
                                 array_shift($segment);
541 541
                             }
542 542
                         }
543 543
                         //check for method
544
-                        if(isset($segment[0])){
544
+                        if (isset($segment[0])) {
545 545
                             $this->method = $segment[0];
546 546
                             array_shift($segment);
547 547
                         }
548 548
                         //the remaining is for args
549 549
                         $this->args = $segment;
550 550
                     }
551
-                    else{
551
+                    else {
552 552
                         $this->logger->info('The current request information is not found in the module list');
553 553
                         //controller
554
-                        if(isset($segment[0])){
554
+                        if (isset($segment[0])) {
555 555
                             $this->controller = $segment[0];
556 556
                             array_shift($segment);
557 557
                         }
558 558
                         //method
559
-                        if(isset($segment[0])){
559
+                        if (isset($segment[0])) {
560 560
                             $this->method = $segment[0];
561 561
                             array_shift($segment);
562 562
                         }
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
                         $this->args = $segment;
565 565
                     }
566 566
                 }
567
-                if(! $this->controller && $this->module){
567
+                if (!$this->controller && $this->module) {
568 568
                     $this->logger->info('After using the request URI the module name is set but the controller is not set so we will use module as the controller');
569 569
                     $this->controller = $this->module;
570 570
                 }
@@ -576,9 +576,9 @@  discard block
 block discarded – undo
576 576
          *
577 577
          * @return object the current instance
578 578
          */
579
-        protected function setRouteConfigurationInfos(){
579
+        protected function setRouteConfigurationInfos() {
580 580
             //adding route
581
-            foreach($this->routes as $pattern => $callback){
581
+            foreach ($this->routes as $pattern => $callback) {
582 582
                 $this->add($pattern, $callback);
583 583
             }
584 584
             return $this;
Please login to merge, or discard this patch.
core/classes/EventDispatcher.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 		 * @param string   $eventName the name of the event to register for
48 48
 		 * @param callable $listener  the function or class method to receive the event information after dispatch
49 49
 		 */
50
-		public function addListener($eventName, callable $listener){
51
-			$this->logger->debug('Adding new event listener for the event name [' .$eventName. '], listener [' .stringfy_vars($listener). ']');
52
-			if(! isset($this->listeners[$eventName])){
50
+		public function addListener($eventName, callable $listener) {
51
+			$this->logger->debug('Adding new event listener for the event name [' . $eventName . '], listener [' . stringfy_vars($listener) . ']');
52
+			if (!isset($this->listeners[$eventName])) {
53 53
 				$this->logger->info('This event does not have the registered event listener before, adding new one');
54 54
 				$this->listeners[$eventName] = array();
55
-			} else{
55
+			} else {
56 56
 				$this->logger->info('This event already have the registered listener, add this listener to the list');
57 57
 			}
58 58
 			$this->listeners[$eventName][] = $listener;
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
 		 * @param  string   $eventName the event name
64 64
 		 * @param  callable $listener  the listener callback
65 65
 		 */
66
-		public function removeListener($eventName, callable $listener){
67
-			$this->logger->debug('Removing of the event listener, the event name [' .$eventName. '], listener [' .stringfy_vars($listener). ']');
68
-			if(isset($this->listeners[$eventName])){
66
+		public function removeListener($eventName, callable $listener) {
67
+			$this->logger->debug('Removing of the event listener, the event name [' . $eventName . '], listener [' . stringfy_vars($listener) . ']');
68
+			if (isset($this->listeners[$eventName])) {
69 69
 				$this->logger->info('This event have the listeners, check if this listener exists');
70
-				if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){
71
-					$this->logger->info('Found the listener at index [' .$index. '] remove it');
70
+				if (false !== $index = array_search($listener, $this->listeners[$eventName], true)) {
71
+					$this->logger->info('Found the listener at index [' . $index . '] remove it');
72 72
 					unset($this->listeners[$eventName][$index]);
73
-				} else{
73
+				} else {
74 74
 					$this->logger->info('Cannot found this listener in the event listener list');
75 75
 				}
76
-			} else{
76
+			} else {
77 77
 				$this->logger->info('This event does not have this listener ignore remove');
78 78
 			}
79 79
 		}
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		 * remove all listeners for this event
84 84
 		 * @param  string $eventName the event name
85 85
 		 */
86
-		public function removeAllListener($eventName = null){
87
-			$this->logger->debug('Removing of all event listener, the event name [' .$eventName. ']');
88
-			if($eventName !== null && isset($this->listeners[$eventName])){
86
+		public function removeAllListener($eventName = null) {
87
+			$this->logger->debug('Removing of all event listener, the event name [' . $eventName . ']');
88
+			if ($eventName !== null && isset($this->listeners[$eventName])) {
89 89
 				$this->logger->info('The event name is set of exist in the listener just remove all event listener for this event');
90 90
 				unset($this->listeners[$eventName]);
91
-			} else{
91
+			} else {
92 92
 				$this->logger->info('The event name is not set or does not exist in the listener, so remove all event listener');
93 93
 				$this->listeners = array();
94 94
 			}
@@ -108,20 +108,20 @@  discard block
 block discarded – undo
108 108
 		 * @param  mixed|object $event the event information
109 109
 		 * @return void|object if event need return, will return the final EventInfo object.
110 110
 		 */	
111
-		public function dispatch($event){
112
-			if(! $event || !$event instanceof EventInfo){
111
+		public function dispatch($event) {
112
+			if (!$event || !$event instanceof EventInfo) {
113 113
 				$this->logger->info('The event is not set or is not an instance of "EventInfo" create the default "EventInfo" object to use instead of.');
114 114
 				$event = new EventInfo((string) $event);
115 115
 			}			
116
-			$this->logger->debug('Dispatch to the event listener, the event [' .stringfy_vars($event). ']');
117
-			if(isset($event->stop) && $event->stop){
116
+			$this->logger->debug('Dispatch to the event listener, the event [' . stringfy_vars($event) . ']');
117
+			if (isset($event->stop) && $event->stop) {
118 118
 				$this->logger->info('This event need stopped, no need call any listener');
119 119
 				return;
120 120
 			}
121
-			if($event->returnBack){
121
+			if ($event->returnBack) {
122 122
 				$this->logger->info('This event need return back, return the result for future use');
123 123
 				return $this->dispatchToListerners($event);
124
-			} else{
124
+			} else {
125 125
 				$this->logger->info('This event no need return back the result, just dispatch it');
126 126
 				$this->dispatchToListerners($event);
127 127
 			}
@@ -132,35 +132,35 @@  discard block
 block discarded – undo
132 132
 		 * @param  object EventInfo $event  the event information
133 133
 		 * @return void|object if event need return, will return the final EventInfo instance.
134 134
 		 */	
135
-		private function dispatchToListerners(EventInfo $event){
135
+		private function dispatchToListerners(EventInfo $event) {
136 136
 			$eBackup = $event;
137 137
 			$list = $this->getListeners($event->name);
138
-			if(empty($list)){
139
-				$this->logger->info('No event listener is registered for the event [' .$event->name. '] skipping.');
140
-				if($event->returnBack){
138
+			if (empty($list)) {
139
+				$this->logger->info('No event listener is registered for the event [' . $event->name . '] skipping.');
140
+				if ($event->returnBack) {
141 141
 					return $event;
142 142
 				}
143 143
 				return;
144
-			} else{
145
-				$this->logger->info('Found the registered event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list));
144
+			} else {
145
+				$this->logger->info('Found the registered event listener for the event [' . $event->name . '] the list are: ' . stringfy_vars($list));
146 146
 			}
147
-			foreach($list as $listener){
148
-				if($eBackup->returnBack){
147
+			foreach ($list as $listener) {
148
+				if ($eBackup->returnBack) {
149 149
 					$returnedEvent = call_user_func_array($listener, array($event));
150
-					if($returnedEvent instanceof EventInfo){
150
+					if ($returnedEvent instanceof EventInfo) {
151 151
 						$event = $returnedEvent;
152
-					} else{
153
-						show_error('This event [' .$event->name. '] need you return the event object after processing');
152
+					} else {
153
+						show_error('This event [' . $event->name . '] need you return the event object after processing');
154 154
 					}
155
-				} else{
155
+				} else {
156 156
 					call_user_func_array($listener, array($event));
157 157
 				}
158
-				if($event->stop){
158
+				if ($event->stop) {
159 159
 					break;
160 160
 				}
161 161
 			}
162 162
 			//only test for original event may be during the flow some listeners change this parameter
163
-			if($eBackup->returnBack){
163
+			if ($eBackup->returnBack) {
164 164
 				return $event;
165 165
 			}
166 166
 		}
Please login to merge, or discard this patch.
core/classes/Log.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
      */
26 26
 
27
-    class Log{
27
+    class Log {
28 28
 		
29 29
         /**
30 30
          * The defined constante for Log level
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
         /**
53 53
          * Create new Log instance
54 54
          */
55
-        public function __construct(){
55
+        public function __construct() {
56 56
         }
57 57
 
58 58
         /**
59 59
          * Set the logger to identify each message in the log
60 60
          * @param string $logger the logger name
61 61
          */
62
-        public  function setLogger($logger){
62
+        public  function setLogger($logger) {
63 63
             $this->logger = $logger;
64 64
         }
65 65
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
          * @see Log::writeLog for more detail
69 69
          * @param  string $message the log message to save
70 70
          */
71
-        public function fatal($message){
71
+        public function fatal($message) {
72 72
             $this->writeLog($message, self::FATAL);
73 73
         } 
74 74
 		
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
          * @see Log::writeLog for more detail
78 78
          * @param  string $message the log message to save
79 79
          */
80
-        public function error($message){
80
+        public function error($message) {
81 81
             $this->writeLog($message, self::ERROR);
82 82
         } 
83 83
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
          * @see Log::writeLog for more detail
87 87
          * @param  string $message the log message to save
88 88
          */
89
-        public function warning($message){
89
+        public function warning($message) {
90 90
             $this->writeLog($message, self::WARNING);
91 91
         } 
92 92
 		
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
          * @see Log::writeLog for more detail
96 96
          * @param  string $message the log message to save
97 97
          */
98
-        public function info($message){
98
+        public function info($message) {
99 99
             $this->writeLog($message, self::INFO);
100 100
         } 
101 101
 		
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
          * @see Log::writeLog for more detail
105 105
          * @param  string $message the log message to save
106 106
          */
107
-        public function debug($message){
107
+        public function debug($message) {
108 108
             $this->writeLog($message, self::DEBUG);
109 109
         } 
110 110
 		
@@ -115,31 +115,31 @@  discard block
 block discarded – undo
115 115
          * @param  integer|string $level   the log level in integer or string format, if is string will convert into integer
116 116
          * to allow check the log level threshold.
117 117
          */
118
-        public function writeLog($message, $level = self::INFO){
118
+        public function writeLog($message, $level = self::INFO) {
119 119
             $configLogLevel = get_config('log_level');
120
-            if(! $configLogLevel){
120
+            if (!$configLogLevel) {
121 121
                 //so means no need log just stop here
122 122
                 return;
123 123
             }
124 124
             //check config log level
125
-            if(! self::isValidConfigLevel($configLogLevel)){
125
+            if (!self::isValidConfigLevel($configLogLevel)) {
126 126
                 //NOTE: here need put the show_error() "logging" to false to prevent loop
127 127
                 show_error('Invalid config log level [' . $configLogLevel . '], the value must be one of the following: ' . implode(', ', array_map('strtoupper', self::$validConfigLevel)), $title = 'Log Config Error', $logging = false);	
128 128
             }
129 129
 			
130 130
             //check if config log_logger_name and current log can save log data
131
-            if(! $this->canSaveLogDataForLogger()){
131
+            if (!$this->canSaveLogDataForLogger()) {
132 132
                 return;
133 133
             }
134 134
 			
135 135
             //if $level is not an integer
136
-            if(! is_numeric($level)){
136
+            if (!is_numeric($level)) {
137 137
                 $level = self::getLevelValue($level);
138 138
             }
139 139
 			
140 140
             //check if can logging regarding the log level config
141 141
             $configLevel = self::getLevelValue($configLogLevel);
142
-            if($configLevel > $level){
142
+            if ($configLevel > $level) {
143 143
                 //can't log
144 144
                 return;
145 145
             }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
          * @param  string $message the log message to save
157 157
          * @return void
158 158
          */
159
-        protected function saveLogData($path, $level, $message){
159
+        protected function saveLogData($path, $level, $message) {
160 160
             //may be at this time helper user_agent not yet included
161 161
             require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php';
162 162
 			
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             $ip = get_ip();
170 170
 			
171 171
             //if $level is not an integer
172
-            if(! is_numeric($level)){
172
+            if (!is_numeric($level)) {
173 173
                 $level = self::getLevelValue($level);
174 174
             }
175 175
 
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
             //debug info
180 180
             $dtrace = debug_backtrace();
181 181
             $fileInfo = $dtrace[0];
182
-            if ($dtrace[0]['file'] == __FILE__ || $dtrace[1]['file'] == __FILE__){
182
+            if ($dtrace[0]['file'] == __FILE__ || $dtrace[1]['file'] == __FILE__) {
183 183
                 $fileInfo = $dtrace[2];
184 184
             }
185 185
 			
186 186
             $str = $logDate . ' [' . str_pad($levelName, 7 /*warning len*/) . '] ' . ' [' . str_pad($ip, 15) . '] ' . $this->logger . ' : ' . $message . ' ' . '[' . $fileInfo['file'] . '::' . $fileInfo['line'] . ']' . "\n";
187 187
             $fp = fopen($path, 'a+');
188
-            if(is_resource($fp)){
188
+            if (is_resource($fp)) {
189 189
                 flock($fp, LOCK_EX); // exclusive lock, will get released when the file is closed
190 190
                 fwrite($fp, $str);
191 191
                 fclose($fp);
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
          * of logger filter
198 198
          * @return boolean
199 199
          */
200
-        protected function canSaveLogDataForLogger(){
201
-            if(! empty($this->logger)){
200
+        protected function canSaveLogDataForLogger() {
201
+            if (!empty($this->logger)) {
202 202
                 $configLoggersName = get_config('log_logger_name', array());
203 203
                 if (!empty($configLoggersName)) {
204 204
                     //for best comparaison put all string to lowercase
205 205
                     $configLoggersName = array_map('strtolower', $configLoggersName);
206
-                    if(! in_array(strtolower($this->logger), $configLoggersName)){
206
+                    if (!in_array(strtolower($this->logger), $configLoggersName)) {
207 207
                         return false;
208 208
                     }
209 209
                 }
@@ -215,19 +215,19 @@  discard block
 block discarded – undo
215 215
          * Check the file and directory 
216 216
          * @return string the log file path
217 217
          */
218
-        protected function checkAndSetLogFileDirectory(){
218
+        protected function checkAndSetLogFileDirectory() {
219 219
             $logSavePath = get_config('log_save_path');
220
-            if(! $logSavePath){
220
+            if (!$logSavePath) {
221 221
                 $logSavePath = LOGS_PATH;
222 222
             }
223 223
 			
224
-            if(! is_dir($logSavePath) || !is_writable($logSavePath)){
224
+            if (!is_dir($logSavePath) || !is_writable($logSavePath)) {
225 225
                 //NOTE: here need put the show_error() "logging" to false to prevent loop
226 226
                 show_error('Error : the log dir does not exists or is not writable', $title = 'Log directory error', $logging = false);
227 227
             }
228 228
 			
229 229
             $path = $logSavePath . 'logs-' . date('Y-m-d') . '.log';
230
-            if(! file_exists($path)){
230
+            if (!file_exists($path)) {
231 231
                 touch($path);
232 232
             }
233 233
             return $path;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
          *
241 241
          * @return boolean        true if the given log level is valid, false if not
242 242
          */
243
-        protected static function isValidConfigLevel($level){
243
+        protected static function isValidConfigLevel($level) {
244 244
             $level = strtolower($level);
245 245
             return in_array($level, self::$validConfigLevel);
246 246
         }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
          * 
252 252
          * @return int        the log level in integer format using the predefined constants
253 253
          */
254
-        protected static function getLevelValue($level){
254
+        protected static function getLevelValue($level) {
255 255
             $level = strtolower($level);
256 256
             $levelMaps = array(
257 257
                 'fatal'   => self::FATAL,
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             );
265 265
             //the default value is NONE, so means no need test for NONE
266 266
             $value = self::NONE;
267
-            if(isset($levelMaps[$level])){
267
+            if (isset($levelMaps[$level])) {
268 268
                 $value = $levelMaps[$level];
269 269
             }
270 270
             return $value;
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
          * @param  integer $level the log level in integer format
276 276
          * @return string        the log level in string format
277 277
          */
278
-        protected static function getLevelName($level){
278
+        protected static function getLevelName($level) {
279 279
             $levelMaps = array(
280 280
                 self::FATAL   => 'FATAL',
281 281
                 self::ERROR   => 'ERROR',
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                 self::DEBUG   => 'DEBUG'
285 285
             );
286 286
             $value = '';
287
-            if(isset($levelMaps[$level])){
287
+            if (isset($levelMaps[$level])) {
288 288
                 $value = $levelMaps[$level];
289 289
             }
290 290
             return $value;
Please login to merge, or discard this patch.
core/classes/Loader.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -74,25 +74,25 @@  discard block
 block discarded – undo
74 74
 			$class  = $moduleInfo['class'];
75 75
 			
76 76
 			$moduleModelFilePath = Module::findModelFullPath($class, $module);
77
-			if ($moduleModelFilePath){
78
-				$logger->info('Found model [' . $class . '] from module [' .$module. '], the file path is [' .$moduleModelFilePath. '] we will used it');
77
+			if ($moduleModelFilePath) {
78
+				$logger->info('Found model [' . $class . '] from module [' . $module . '], the file path is [' . $moduleModelFilePath . '] we will used it');
79 79
 				$classFilePath = $moduleModelFilePath;
80
-			} else{
80
+			} else {
81 81
 				$logger->info('Cannot find model [' . $class . '] from modules using the default location');
82 82
 			}
83 83
 			$logger->info('The model file path to be loaded is [' . $classFilePath . ']');
84
-			if (file_exists($classFilePath)){
84
+			if (file_exists($classFilePath)) {
85 85
 				require_once $classFilePath;
86
-				if (class_exists($class)){
86
+				if (class_exists($class)) {
87 87
 					$c = new $class();
88 88
 					$obj = & get_instance();
89 89
 					$obj->{$instance} = $c;
90 90
 					static::$loaded[$instance] = $class;
91 91
 					$logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.');
92
-				} else{
93
-					show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']');
92
+				} else {
93
+					show_error('The file ' . $classFilePath . ' exists but does not contain the class [' . $class . ']');
94 94
 				}
95
-			} else{
95
+			} else {
96 96
 				show_error('Unable to find the model [' . $class . ']');
97 97
 			}
98 98
 		}
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 			}
132 132
 			$libraryFilePath = null;
133 133
 			$logger->debug('Check if this is a system library ...');
134
-			if (file_exists(CORE_LIBRARY_PATH . $file)){
134
+			if (file_exists(CORE_LIBRARY_PATH . $file)) {
135 135
 				$libraryFilePath = CORE_LIBRARY_PATH . $file;
136 136
 				$class = ucfirst($class);
137 137
 				$logger->info('This library is a system library');
138
-			} else{
138
+			} else {
139 139
 				$logger->info('This library is not a system library');	
140 140
 				//first check if this library is in the module
141 141
 				$libraryFilePath = self::getLibraryPathUsingModuleInfo($class);
142 142
 				//***************
143 143
 			}
144
-			if (! $libraryFilePath && file_exists(LIBRARY_PATH . $file)){
144
+			if (!$libraryFilePath && file_exists(LIBRARY_PATH . $file)) {
145 145
 				$libraryFilePath = LIBRARY_PATH . $file;
146 146
 			}
147 147
 			$logger->info('The library file path to be loaded is [' . $libraryFilePath . ']');
@@ -173,21 +173,21 @@  discard block
 block discarded – undo
173 173
 			$moduleInfo = self::getModuleInfoForFunction($function);
174 174
 			$module    = $moduleInfo['module'];
175 175
 			$function  = $moduleInfo['function'];
176
-			if(! empty($moduleInfo['file'])){
176
+			if (!empty($moduleInfo['file'])) {
177 177
 				$file = $moduleInfo['file'];
178 178
 			}
179 179
 			$moduleFunctionPath = Module::findFunctionFullPath($function, $module);
180
-			if ($moduleFunctionPath){
181
-				$logger->info('Found helper [' . $function . '] from module [' .$module. '], the file path is [' .$moduleFunctionPath. '] we will used it');
180
+			if ($moduleFunctionPath) {
181
+				$logger->info('Found helper [' . $function . '] from module [' . $module . '], the file path is [' . $moduleFunctionPath . '] we will used it');
182 182
 				$functionFilePath = $moduleFunctionPath;
183
-			} else{
183
+			} else {
184 184
 				$logger->info('Cannot find helper [' . $function . '] from modules using the default location');
185 185
 			}
186
-			if (! $functionFilePath){
186
+			if (!$functionFilePath) {
187 187
 				$searchDir = array(FUNCTIONS_PATH, CORE_FUNCTIONS_PATH);
188
-				foreach($searchDir as $dir){
188
+				foreach ($searchDir as $dir) {
189 189
 					$filePath = $dir . $file;
190
-					if (file_exists($filePath)){
190
+					if (file_exists($filePath)) {
191 191
 						$functionFilePath = $filePath;
192 192
 						//is already found not to continue
193 193
 						break;
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 				}
196 196
 			}
197 197
 			$logger->info('The helper file path to be loaded is [' . $functionFilePath . ']');
198
-			if ($functionFilePath){
198
+			if ($functionFilePath) {
199 199
 				require_once $functionFilePath;
200 200
 				static::$loaded['function_' . $function] = $functionFilePath;
201 201
 				$logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.');
202
-			} else{
202
+			} else {
203 203
 				show_error('Unable to find helper file [' . $file . ']');
204 204
 			}
205 205
 		}
@@ -229,25 +229,25 @@  discard block
 block discarded – undo
229 229
 			$module    = $moduleInfo['module'];
230 230
 			$filename  = $moduleInfo['filename'];
231 231
 			$moduleConfigPath = Module::findConfigFullPath($filename, $module);
232
-			if ($moduleConfigPath){
233
-				$logger->info('Found config [' . $filename . '] from module [' .$module. '], the file path is [' .$moduleConfigPath. '] we will used it');
232
+			if ($moduleConfigPath) {
233
+				$logger->info('Found config [' . $filename . '] from module [' . $module . '], the file path is [' . $moduleConfigPath . '] we will used it');
234 234
 				$configFilePath = $moduleConfigPath;
235
-			} else{
235
+			} else {
236 236
 				$logger->info('Cannot find config [' . $filename . '] from modules using the default location');
237 237
 			}
238 238
 			$logger->info('The config file path to be loaded is [' . $configFilePath . ']');
239 239
 			$config = array();
240
-			if (file_exists($configFilePath)){
240
+			if (file_exists($configFilePath)) {
241 241
 				require_once $configFilePath;
242
-				if (! empty($config) && is_array($config)){
242
+				if (!empty($config) && is_array($config)) {
243 243
 					Config::setAll($config);
244 244
 					static::$loaded['config_' . $filename] = $configFilePath;
245 245
 					$logger->info('Configuration [' . $configFilePath . '] loaded successfully.');
246 246
 					$logger->info('The custom application configuration loaded are listed below: ' . stringfy_vars($config));
247 247
 					unset($config);
248 248
 				}
249
-			} else{
250
-				show_error('Unable to find config file ['. $configFilePath . ']');
249
+			} else {
250
+				show_error('Unable to find config file [' . $configFilePath . ']');
251 251
 			}
252 252
 		}
253 253
 
@@ -278,21 +278,21 @@  discard block
 block discarded – undo
278 278
 			$moduleInfo = self::getModuleInfoForLanguage($language);
279 279
 			$module    = $moduleInfo['module'];
280 280
 			$language  = $moduleInfo['language'];
281
-			if(! empty($moduleInfo['file'])){
281
+			if (!empty($moduleInfo['file'])) {
282 282
 				$file = $moduleInfo['file'];
283 283
 			}
284 284
 			$moduleLanguagePath = Module::findLanguageFullPath($language, $appLang, $module);
285
-			if ($moduleLanguagePath){
286
-				$logger->info('Found language [' . $language . '] from module [' .$module. '], the file path is [' .$moduleLanguagePath. '] we will used it');
285
+			if ($moduleLanguagePath) {
286
+				$logger->info('Found language [' . $language . '] from module [' . $module . '], the file path is [' . $moduleLanguagePath . '] we will used it');
287 287
 				$languageFilePath = $moduleLanguagePath;
288
-			} else{
288
+			} else {
289 289
 				$logger->info('Cannot find language [' . $language . '] from modules using the default location');
290 290
 			}
291
-			if (! $languageFilePath){
291
+			if (!$languageFilePath) {
292 292
 				$searchDir = array(APP_LANG_PATH, CORE_LANG_PATH);
293
-				foreach($searchDir as $dir){
293
+				foreach ($searchDir as $dir) {
294 294
 					$filePath = $dir . $appLang . DS . $file;
295
-					if (file_exists($filePath)){
295
+					if (file_exists($filePath)) {
296 296
 						$languageFilePath = $filePath;
297 297
 						//already found no need continue
298 298
 						break;
@@ -329,19 +329,19 @@  discard block
 block discarded – undo
329 329
 		 * 	'class' => 'class_name'
330 330
 		 * )
331 331
 		 */
332
-		protected static function getModuleInfoForModelLibrary($class){
332
+		protected static function getModuleInfoForModelLibrary($class) {
333 333
 			$module = null;
334 334
 			$obj = & get_instance();
335
-			if (strpos($class, '/') !== false){
335
+			if (strpos($class, '/') !== false) {
336 336
 				$path = explode('/', $class);
337
-				if (isset($path[0]) && in_array($path[0], Module::getModuleList())){
337
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
338 338
 					$module = $path[0];
339 339
 					$class = ucfirst($path[1]);
340 340
 				}
341
-			} else{
341
+			} else {
342 342
 				$class = ucfirst($class);
343 343
 			}
344
-			if (! $module && !empty($obj->moduleName)){
344
+			if (!$module && !empty($obj->moduleName)) {
345 345
 				$module = $obj->moduleName;
346 346
 			}
347 347
 			return array(
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
 		 * @param  string $class the class name to determine the instance
452 452
 		 * @return string        the instance name
453 453
 		 */
454
-		protected static function getModelLibraryInstanceName($class){
454
+		protected static function getModelLibraryInstanceName($class) {
455 455
 			//for module
456 456
 			$instance = null;
457
-			if (strpos($class, '/') !== false){
457
+			if (strpos($class, '/') !== false) {
458 458
 				$path = explode('/', $class);
459
-				if (isset($path[1])){
459
+				if (isset($path[1])) {
460 460
 					$instance = strtolower($path[1]);
461 461
 				}
462
-			} else{
462
+			} else {
463 463
 				$instance = strtolower($class);
464 464
 			}
465 465
 			return $instance;
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 			$module = $moduleInfo['module'];
479 479
 			$class  = $moduleInfo['class'];
480 480
 			$moduleLibraryPath = Module::findLibraryFullPath($class, $module);
481
-			if ($moduleLibraryPath){
482
-				$logger->info('Found library [' . $class . '] from module [' .$module. '], the file path is [' .$moduleLibraryPath. '] we will used it');
481
+			if ($moduleLibraryPath) {
482
+				$logger->info('Found library [' . $class . '] from module [' . $module . '], the file path is [' . $moduleLibraryPath . '] we will used it');
483 483
 				$libraryFilePath = $moduleLibraryPath;
484
-			} else{
484
+			} else {
485 485
 				$logger->info('Cannot find library [' . $class . '] from modules using the default location');
486 486
 			}
487 487
 			return $libraryFilePath;
@@ -495,20 +495,20 @@  discard block
 block discarded – undo
495 495
 		 * @param  array  $params          the parameter to use
496 496
 		 * @return void
497 497
 		 */
498
-		protected static function loadLibrary($libraryFilePath, $class, $instance, $params = array()){
499
-			if ($libraryFilePath){
498
+		protected static function loadLibrary($libraryFilePath, $class, $instance, $params = array()) {
499
+			if ($libraryFilePath) {
500 500
 				$logger = static::getLogger();
501 501
 				require_once $libraryFilePath;
502
-				if (class_exists($class)){
502
+				if (class_exists($class)) {
503 503
 					$c = $params ? new $class($params) : new $class();
504 504
 					$obj = & get_instance();
505 505
 					$obj->{$instance} = $c;
506 506
 					static::$loaded[$instance] = $class;
507 507
 					$logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.');
508
-				} else{
509
-					show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class);
508
+				} else {
509
+					show_error('The file ' . $libraryFilePath . ' exists but does not contain the class ' . $class);
510 510
 				}
511
-			} else{
511
+			} else {
512 512
 				show_error('Unable to find library class [' . $class . ']');
513 513
 			}
514 514
 		}
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 				}
535 535
 				static::$loaded['lang_' . $language] = $languageFilePath;
536 536
 				$logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.');
537
-			} else{
537
+			} else {
538 538
 				show_error('Unable to find language [' . $language . ']');
539 539
 			}
540 540
 		}
Please login to merge, or discard this patch.
core/classes/Controller.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
      */
26 26
 
27
-    class Controller extends BaseClass{
27
+    class Controller extends BaseClass {
28 28
 		
29 29
         /**
30 30
          * The name of the module if this controller belong to an module
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         /**
43 43
          * Class constructor
44 44
          */
45
-        public function __construct(){
45
+        public function __construct() {
46 46
             parent::__construct();
47 47
 			
48 48
             //instance of the super object
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 
51 51
             //Load the resources loaded during the application bootstrap
52 52
             $this->logger->debug('Adding the loaded classes to the super instance');
53
-            foreach (class_loaded() as $var => $class){
54
-                $this->$var =& class_loader($class);
53
+            foreach (class_loaded() as $var => $class) {
54
+                $this->$var = & class_loader($class);
55 55
             }
56 56
 			
57 57
             //set module using the router
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
         /**
84 84
          * This method is used to set the module name
85 85
          */
86
-        protected function setModuleNameFromRouter(){
86
+        protected function setModuleNameFromRouter() {
87 87
             //set the module using the router instance
88
-            if(isset($this->router) && $this->router->getModule()){
88
+            if (isset($this->router) && $this->router->getModule()) {
89 89
                 $this->moduleName = $this->router->getModule();
90 90
             }
91 91
         }
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
          * Set the cache using the argument otherwise will use the configuration
95 95
          * @param CacheInterface $cache the implementation of CacheInterface if null will use the configured
96 96
          */
97
-        protected function setCacheFromParamOrConfig(CacheInterface $cache = null){
97
+        protected function setCacheFromParamOrConfig(CacheInterface $cache = null) {
98 98
             $this->logger->debug('Setting the cache handler instance');
99 99
             //set cache handler instance
100
-            if(get_config('cache_enable', false)){
101
-                if ($cache !== null){
100
+            if (get_config('cache_enable', false)) {
101
+                if ($cache !== null) {
102 102
                     $this->cache = $cache;
103
-                } else if (isset($this->{strtolower(get_config('cache_handler'))})){
103
+                } else if (isset($this->{strtolower(get_config('cache_handler'))})) {
104 104
                     $this->cache = $this->{strtolower(get_config('cache_handler'))};
105 105
                     unset($this->{strtolower(get_config('cache_handler'))});
106 106
                 } 
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
          * This method is used to load the required resources for framework to work
113 113
          * @return void 
114 114
          */
115
-        private function loadRequiredResources(){
115
+        private function loadRequiredResources() {
116 116
             $this->logger->debug('Loading the required classes into super instance');
117
-            $this->eventdispatcher =& class_loader('EventDispatcher', 'classes');
118
-            $this->loader =& class_loader('Loader', 'classes');
119
-            $this->lang =& class_loader('Lang', 'classes');
120
-            $this->request =& class_loader('Request', 'classes');
117
+            $this->eventdispatcher = & class_loader('EventDispatcher', 'classes');
118
+            $this->loader = & class_loader('Loader', 'classes');
119
+            $this->lang = & class_loader('Lang', 'classes');
120
+            $this->request = & class_loader('Request', 'classes');
121 121
             //dispatch the request instance created event
122 122
             $this->eventdispatcher->dispatch('REQUEST_CREATED');
123
-            $this->response =& class_loader('Response', 'classes', 'classes');
123
+            $this->response = & class_loader('Response', 'classes', 'classes');
124 124
         }
125 125
 
126 126
     }
Please login to merge, or discard this patch.