Test Failed
Push — 1.0.0-dev ( 659da7...aa6afc )
by nguereza
04:16
created
core/classes/cache/FileCache.php 1 patch
Spacing   +62 added lines, -62 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 implements CacheInterface{
27
+	class FileCache implements CacheInterface {
28 28
 		
29 29
 		/**
30 30
 		 * Whether to enable compression of the cache data file.
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
 		private $logger;
40 40
 		
41 41
 		
42
-		public function __construct(Log $logger = null){
43
-			if(! $this->isSupported()){
42
+		public function __construct(Log $logger = null) {
43
+			if (!$this->isSupported()) {
44 44
 				show_error('The cache for file system is not available. Check the cache directory if is exists or is writable.');
45 45
 			}
46 46
 			/**
47 47
 	         * instance of the Log class
48 48
 	         */
49
-	        if(is_object($logger)){
49
+	        if (is_object($logger)) {
50 50
 	          $this->logger = $logger;
51 51
 	        }
52
-	        else{
53
-	            $this->logger =& class_loader('Log', 'classes');
52
+	        else {
53
+	            $this->logger = & class_loader('Log', 'classes');
54 54
 	            $this->logger->setLogger('Library::FileCache');
55 55
 	        }
56 56
 			
57 57
 			//if Zlib extension is not loaded set compressCacheData to false
58
-			if(! extension_loaded('zlib')){
58
+			if (!extension_loaded('zlib')) {
59 59
 				$this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
60 60
 				$this->compressCacheData = false;
61 61
 			}
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 		 * @param  string $key the key to identify the cache data
67 67
 		 * @return mixed      the cache data if exists else return false
68 68
 		 */
69
-		public function get($key){
70
-			$this->logger->debug('Getting cache data for key ['. $key .']');
69
+		public function get($key) {
70
+			$this->logger->debug('Getting cache data for key [' . $key . ']');
71 71
 			$filePath = $this->getFilePath($key);
72
-			if(! file_exists($filePath)){
73
-				$this->logger->info('No cache file found for the key ['. $key .'], return false');
72
+			if (!file_exists($filePath)) {
73
+				$this->logger->info('No cache file found for the key [' . $key . '], return false');
74 74
 				return false;
75 75
 			}
76
-			$this->logger->info('The cache file [' .$filePath. '] for the key ['. $key .'] exists, check if the cache data is valid');
77
-			$handle = fopen($filePath,'r');
78
-			if( ! $handle){
79
-				$this->logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
76
+			$this->logger->info('The cache file [' . $filePath . '] for the key [' . $key . '] exists, check if the cache data is valid');
77
+			$handle = fopen($filePath, 'r');
78
+			if (!$handle) {
79
+				$this->logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
80 80
 				return false;
81 81
 			}
82 82
 			// Getting a shared lock 
@@ -84,20 +84,20 @@  discard block
 block discarded – undo
84 84
 		    $data = file_get_contents($filePath);
85 85
       		fclose($handle);
86 86
       		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
87
-      		if (! $data) {
88
-      			$this->logger->error('Can not unserialize the cache data for the key ['. $key .'], return false');
87
+      		if (!$data) {
88
+      			$this->logger->error('Can not unserialize the cache data for the key [' . $key . '], return false');
89 89
 		         // If unserializing somehow didn't work out, we'll delete the file
90 90
 		         unlink($filePath);
91 91
 		         return false;
92 92
 	      	}
93 93
 	      	if (time() > $data['expire']) {
94
-	      		$this->logger->info('The cache data for the key ['. $key .'] already expired delete the cache file [' .$filePath. ']');
94
+	      		$this->logger->info('The cache data for the key [' . $key . '] already expired delete the cache file [' . $filePath . ']');
95 95
 		        // Unlinking when the file was expired
96 96
 		        unlink($filePath);
97 97
 		        return false;
98 98
 		     }
99
-		     else{
100
-		     	$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']) . ']');
99
+		     else {
100
+		     	$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']) . ']');
101 101
 		     	return $data['data'];
102 102
 		     }
103 103
 			return false;
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 		 * @param integer $ttl  the cache life time
112 112
 		 * @return boolean true if success otherwise will return false
113 113
 		 */
114
-		public function set($key, $data, $ttl = 0){
114
+		public function set($key, $data, $ttl = 0) {
115 115
 			$expire = time() + $ttl;
116
-			$this->logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
116
+			$this->logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
117 117
 			$filePath = $this->getFilePath($key);
118
-			$handle = fopen($filePath,'w');
119
-			if( ! $handle){
120
-				$this->logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
118
+			$handle = fopen($filePath, 'w');
119
+			if (!$handle) {
120
+				$this->logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
121 121
 				return false;
122 122
 			}
123 123
 			flock($handle, LOCK_EX); // exclusive lock, will get released when the file is closed
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 									)
131 131
 								);		   
132 132
 		    $result = fwrite($handle, $this->compressCacheData ? gzdeflate($cacheData, 9) : $cacheData);
133
-		    if(! $result){
134
-		    	$this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
133
+		    if (!$result) {
134
+		    	$this->logger->error('Can not write cache data into file [' . $filePath . '] for the key [' . $key . '], return false');
135 135
 		    	fclose($handle);
136 136
 		    	return false;
137 137
 		    }
138
-		    else{
139
-		    	$this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
138
+		    else {
139
+		    	$this->logger->info('Cache data saved into file [' . $filePath . '] for the key [' . $key . ']');
140 140
 		    	fclose($handle);
141 141
 				chmod($filePath, 0640);
142 142
 				return true;
@@ -150,16 +150,16 @@  discard block
 block discarded – undo
150 150
 		 * @return boolean      true if the cache is delete, false if can't delete 
151 151
 		 * the cache or the cache with the given key not exist
152 152
 		 */
153
-		public function delete($key){
154
-			$this->logger->debug('Deleting of cache data for key [' .$key. ']');
153
+		public function delete($key) {
154
+			$this->logger->debug('Deleting of cache data for key [' . $key . ']');
155 155
 			$filePath = $this->getFilePath($key);
156
-			$this->logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
157
-			if(! file_exists($filePath)){
156
+			$this->logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
157
+			if (!file_exists($filePath)) {
158 158
 				$this->logger->info('This cache file does not exists skipping');
159 159
 				return false;
160 160
 			}
161
-			else{
162
-				$this->logger->info('Found cache file [' .$filePath. '] remove it');
161
+			else {
162
+				$this->logger->info('Found cache file [' . $filePath . '] remove it');
163 163
 	      		@unlink($filePath);
164 164
 				return true;
165 165
 			}
@@ -173,25 +173,25 @@  discard block
 block discarded – undo
173 173
 		 * 'expire' => expiration time of the cache (Unix timestamp),
174 174
 		 * 'ttl' => the time to live of the cache in second
175 175
 		 */
176
-		public function getInfo($key){
177
-			$this->logger->debug('Getting of cache info for key [' .$key. ']');
176
+		public function getInfo($key) {
177
+			$this->logger->debug('Getting of cache info for key [' . $key . ']');
178 178
 			$filePath = $this->getFilePath($key);
179
-			$this->logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
180
-			if(! file_exists($filePath)){
179
+			$this->logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
180
+			if (!file_exists($filePath)) {
181 181
 				$this->logger->info('This cache file does not exists skipping');
182 182
 				return false;
183 183
 			}
184
-			else{
185
-				$this->logger->info('Found cache file [' .$filePath. '] check the validity');
184
+			else {
185
+				$this->logger->info('Found cache file [' . $filePath . '] check the validity');
186 186
 	      		$data = file_get_contents($filePath);
187 187
 				$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
188
-				if(! $data){
188
+				if (!$data) {
189 189
 					$this->logger->warning('Can not unserialize the cache data for file [' . $filePath . ']');
190 190
 					return false;
191 191
 				}
192
-				else{
192
+				else {
193 193
 					$this->logger->info('This cache data is OK check for expire');
194
-					if(isset($data['expire']) && $data['expire'] > time()){
194
+					if (isset($data['expire']) && $data['expire'] > time()) {
195 195
 						$this->logger->info('This cache not yet expired return cache informations');
196 196
 						$info = array(
197 197
 							'mtime' => $data['mtime'],
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 							);
201 201
 						return $info;
202 202
 					}
203
-					else{
203
+					else {
204 204
 						$this->logger->info('This cache already expired return false');
205 205
 						return false;
206 206
 					}
@@ -212,26 +212,26 @@  discard block
 block discarded – undo
212 212
 		/**
213 213
 		 * Used to delete expired cache data
214 214
 		 */
215
-		public function deleteExpiredCache(){
215
+		public function deleteExpiredCache() {
216 216
 			$this->logger->debug('Deleting of expired cache files');
217 217
 			$list = glob(CACHE_PATH . '*.cache');
218
-			if(! $list){
218
+			if (!$list) {
219 219
 				$this->logger->info('No cache files were found skipping');
220 220
 			}
221
-			else{
221
+			else {
222 222
 				$this->logger->info('Found [' . count($list) . '] cache files to remove if expired');
223 223
 				foreach ($list as $file) {
224 224
 					$this->logger->debug('Processing the cache file [' . $file . ']');
225 225
 					$data = file_get_contents($file);
226 226
 		      		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
227
-		      		if(! $data){
227
+		      		if (!$data) {
228 228
 		      			$this->logger->warning('Can not unserialize the cache data for file [' . $file . ']');
229 229
 		      		}
230
-		      		else if(time() > $data['expire']){
230
+		      		else if (time() > $data['expire']) {
231 231
 		      			$this->logger->info('The cache data for file [' . $file . '] already expired remove it');
232 232
 		      			@unlink($file);
233 233
 		      		}
234
-		      		else{
234
+		      		else {
235 235
 		      			$this->logger->info('The cache data for file [' . $file . '] not yet expired skip it');
236 236
 		      		}
237 237
 				}
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
 		/**
242 242
 		 * Remove all file from cache folder
243 243
 		 */
244
-		public function clean(){
244
+		public function clean() {
245 245
 			$this->logger->debug('Deleting of all cache files');
246 246
 			$list = glob(CACHE_PATH . '*.cache');
247
-			if(! $list){
247
+			if (!$list) {
248 248
 				$this->logger->info('No cache files were found skipping');
249 249
 			}
250
-			else{
250
+			else {
251 251
 				$this->logger->info('Found [' . count($list) . '] cache files to remove');
252 252
 				foreach ($list as $file) {
253 253
 					$this->logger->debug('Processing the cache file [' . $file . ']');
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	    /**
260 260
 	     * @return boolean
261 261
 	     */
262
-	    public function isCompressCacheData(){
262
+	    public function isCompressCacheData() {
263 263
 	        return $this->compressCacheData;
264 264
 	    }
265 265
 
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
 	     *
269 269
 	     * @return self
270 270
 	     */
271
-	    public function setCompressCacheData($status = true){
271
+	    public function setCompressCacheData($status = true) {
272 272
 			//if Zlib extension is not loaded set compressCacheData to false
273
-			if($status === true && ! extension_loaded('zlib')){
273
+			if ($status === true && !extension_loaded('zlib')) {
274 274
 				
275 275
 				$this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
276 276
 				$this->compressCacheData = false;
277 277
 			}
278
-			else{
278
+			else {
279 279
 				$this->compressCacheData = $status;
280 280
 			}
281 281
 			return $this;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		 *
287 287
 		 * @return bool
288 288
 		 */
289
-		public function isSupported(){
289
+		public function isSupported() {
290 290
 			return CACHE_PATH && is_dir(CACHE_PATH) && is_writable(CACHE_PATH);
291 291
 		}
292 292
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	     * Return the Log instance
295 295
 	     * @return Log
296 296
 	     */
297
-	    public function getLogger(){
297
+	    public function getLogger() {
298 298
 	      return $this->logger;
299 299
 	    }
300 300
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	     * Set the log instance
303 303
 	     * @param Log $logger the log object
304 304
 	     */
305
-	    public function setLogger(Log $logger){
305
+	    public function setLogger(Log $logger) {
306 306
 	      $this->logger = $logger;
307 307
 	      return $this;
308 308
 	    }
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		* @param $key the cache item key
314 314
 		* @return string the full cache file path for this key
315 315
 		*/
316
-		private function getFilePath($key){
316
+		private function getFilePath($key) {
317 317
 			return CACHE_PATH . md5($key) . '.cache';
318 318
 		}
319 319
 	}
Please login to merge, or discard this patch.
core/classes/cache/ApcCache.php 1 patch
Spacing   +39 added lines, -39 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 ApcCache implements CacheInterface{
27
+	class ApcCache implements CacheInterface {
28 28
 
29 29
 		/**
30 30
 		 * The logger instance
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 		private $logger;
34 34
 		
35 35
 		
36
-		public function __construct(Log $logger = null){
37
-			if(! $this->isSupported()){
36
+		public function __construct(Log $logger = null) {
37
+			if (!$this->isSupported()) {
38 38
 				show_error('The cache for APC[u] driver is not available. Check if APC[u] extension is loaded and enabled.');
39 39
 			}
40 40
 
41 41
 			/**
42 42
 	         * instance of the Log class
43 43
 	         */
44
-	        if(is_object($logger)){
44
+	        if (is_object($logger)) {
45 45
 	          $this->logger = $logger;
46 46
 	        }
47
-	        else{
48
-	            $this->logger =& class_loader('Log', 'classes');
47
+	        else {
48
+	            $this->logger = & class_loader('Log', 'classes');
49 49
 	            $this->logger->setLogger('Library::ApcCache');
50 50
 	        }
51 51
 		}
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
 		 * @param  string $key the key to identify the cache data
56 56
 		 * @return mixed      the cache data if exists else return false
57 57
 		 */
58
-		public function get($key){
59
-			$this->logger->debug('Getting cache data for key ['. $key .']');
58
+		public function get($key) {
59
+			$this->logger->debug('Getting cache data for key [' . $key . ']');
60 60
 			$success = false;
61 61
 			$data = apc_fetch($key, $success);
62
-			if($success === false){
63
-				$this->logger->info('No cache found for the key ['. $key .'], return false');
62
+			if ($success === false) {
63
+				$this->logger->info('No cache found for the key [' . $key . '], return false');
64 64
 				return false;
65 65
 			}
66
-			else{
66
+			else {
67 67
 				$cacheInfo = $this->_getCacheInfo($key);
68 68
 				$expire = time();
69
-				if($cacheInfo){
69
+				if ($cacheInfo) {
70 70
 					$expire = $cacheInfo['creation_time'] + $cacheInfo['ttl'];
71 71
 				}
72
-				$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) . ']');
72
+				$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) . ']');
73 73
 				return $data;
74 74
 			}
75 75
 		}
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 		 * @param integer $ttl  the cache life time
83 83
 		 * @return boolean true if success otherwise will return false
84 84
 		 */
85
-		public function set($key, $data, $ttl = 0){
85
+		public function set($key, $data, $ttl = 0) {
86 86
 			$expire = time() + $ttl;
87
-			$this->logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
87
+			$this->logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
88 88
 			$result = apc_store($key, $data, $ttl);
89
-			if($result === false){
90
-		    	$this->logger->error('Can not write cache data for the key ['. $key .'], return false');
89
+			if ($result === false) {
90
+		    	$this->logger->error('Can not write cache data for the key [' . $key . '], return false');
91 91
 		    	return false;
92 92
 		    }
93
-		    else{
94
-		    	$this->logger->info('Cache data saved for the key ['. $key .']');
93
+		    else {
94
+		    	$this->logger->info('Cache data saved for the key [' . $key . ']');
95 95
 		    	return true;
96 96
 		    }
97 97
 		}
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 		 * @return boolean      true if the cache is deleted, false if can't delete 
104 104
 		 * the cache or the cache with the given key not exist
105 105
 		 */
106
-		public function delete($key){
107
-			$this->logger->debug('Deleting of cache data for key [' .$key. ']');
106
+		public function delete($key) {
107
+			$this->logger->debug('Deleting of cache data for key [' . $key . ']');
108 108
 			$cacheInfo = $this->_getCacheInfo($key);
109
-			if($cacheInfo === false){
109
+			if ($cacheInfo === false) {
110 110
 				$this->logger->info('This cache data does not exists skipping');
111 111
 				return false;
112 112
 			}
113
-			else{
114
-				$this->logger->info('Found cache data for the key [' .$key. '] remove it');
113
+			else {
114
+				$this->logger->info('Found cache data for the key [' . $key . '] remove it');
115 115
 	      		return apc_delete($key);
116 116
 			}
117 117
 			return false;
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 		 * 'expire' => expiration time of the cache (Unix timestamp),
126 126
 		 * 'ttl' => the time to live of the cache in second
127 127
 		 */
128
-		public function getInfo($key){
129
-			$this->logger->debug('Getting of cache info for key [' .$key. ']');
128
+		public function getInfo($key) {
129
+			$this->logger->debug('Getting of cache info for key [' . $key . ']');
130 130
 			$cacheInfos = $this->_getCacheInfo($key);
131
-			if($cacheInfos){
131
+			if ($cacheInfos) {
132 132
 				$data = array(
133 133
 							'mtime' => $cacheInfos['creation_time'],
134 134
 							'expire' => $cacheInfos['creation_time'] + $cacheInfos['ttl'],
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 							);
137 137
 				return $data;
138 138
 			}
139
-			else{
139
+			else {
140 140
 				$this->logger->info('This cache does not exists skipping');
141 141
 				return false;
142 142
 			}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		/**
147 147
 		 * Used to delete expired cache data
148 148
 		 */
149
-		public function deleteExpiredCache(){
149
+		public function deleteExpiredCache() {
150 150
 			//for APC[u] is done automatically
151 151
 			return true;
152 152
 		}
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 		/**
155 155
 		 * Remove all cache data
156 156
 		 */
157
-		public function clean(){
157
+		public function clean() {
158 158
 			$this->logger->debug('Deleting of all cache data');
159 159
 			$cacheInfos = apc_cache_info('user');
160
-			if(empty($cacheInfos['cache_list'])){
160
+			if (empty($cacheInfos['cache_list'])) {
161 161
 				$this->logger->info('No cache data were found skipping');
162 162
 				return false;
163 163
 			}
164
-			else{
164
+			else {
165 165
 				$this->logger->info('Found [' . count($cacheInfos) . '] cache data to remove');
166 166
 				return apc_clear_cache('user');
167 167
 			}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		 *
174 174
 		 * @return bool
175 175
 		 */
176
-		public function isSupported(){
176
+		public function isSupported() {
177 177
 			return (extension_loaded('apc') || extension_loaded('apcu')) && ini_get('apc.enabled');
178 178
 		}
179 179
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	     * Return the Log instance
182 182
 	     * @return Log
183 183
 	     */
184
-	    public function getLogger(){
184
+	    public function getLogger() {
185 185
 	      return $this->logger;
186 186
 	    }
187 187
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	     * Set the log instance
190 190
 	     * @param Log $logger the log object
191 191
 	     */
192
-	    public function setLogger(Log $logger){
192
+	    public function setLogger(Log $logger) {
193 193
 	      $this->logger = $logger;
194 194
 	      return $this;
195 195
 	    }
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
 		* @param string $key the cache key to get the cache information 
201 201
 		* @return array
202 202
 		*/
203
-		private function _getCacheInfo($key){
203
+		private function _getCacheInfo($key) {
204 204
 			$caches = apc_cache_info('user');
205
-			if(! empty($caches['cache_list'])){
205
+			if (!empty($caches['cache_list'])) {
206 206
 				$cacheLists = $caches['cache_list'];
207
-				foreach ($cacheLists as $c){
208
-					if(isset($c['info']) && $c['info'] === $key){
207
+				foreach ($cacheLists as $c) {
208
+					if (isset($c['info']) && $c['info'] === $key) {
209 209
 						return $c;
210 210
 					}
211 211
 				}
Please login to merge, or discard this patch.
core/classes/Lang.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * For application languages management
29 29
 	 */
30
-	class Lang{
30
+	class Lang {
31 31
 		
32 32
 		/**
33 33
 		 * The supported available language for this application.
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 		/**
68 68
 		 * Construct new Lang instance
69 69
 		 */
70
-		public function __construct(){
71
-	        $this->logger =& class_loader('Log', 'classes');
70
+		public function __construct() {
71
+	        $this->logger = & class_loader('Log', 'classes');
72 72
 	        $this->logger->setLogger('Library::Lang');
73 73
 
74 74
 			$this->default = get_config('default_language', 'en');
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 			
77 77
 			//add the supported languages ('key', 'display name')
78 78
 			$languages = get_config('languages', null);
79
-			if(! empty($languages)){
80
-				foreach($languages as $key => $displayName){
79
+			if (!empty($languages)) {
80
+				foreach ($languages as $key => $displayName) {
81 81
 					$this->addLang($key, $displayName);
82 82
 				}
83 83
 			}
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 			$language = null;
88 88
 			//if the language exists in cookie use it
89 89
 			$cfgKey = get_config('language_cookie_name');
90
-			$this->logger->debug('Getting current language from cookie [' .$cfgKey. ']');
90
+			$this->logger->debug('Getting current language from cookie [' . $cfgKey . ']');
91 91
 			$objCookie = & class_loader('Cookie');
92 92
 			$cookieLang = $objCookie->get($cfgKey);
93
-			if($cookieLang && $this->isValid($cookieLang)){
93
+			if ($cookieLang && $this->isValid($cookieLang)) {
94 94
 				$this->current = $cookieLang;
95
-				$this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']');
95
+				$this->logger->info('Language from cookie [' . $cfgKey . '] is valid so we will set the language using the cookie value [' . $cookieLang . ']');
96 96
 			}
97
-			else{
98
-				$this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']');
97
+			else {
98
+				$this->logger->info('Language from cookie [' . $cfgKey . '] is not set, use the default value [' . $this->getDefault() . ']');
99 99
 				$this->current = $this->getDefault();
100 100
 			}
101 101
 		}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		 *
106 106
 		 * @return array the language message list
107 107
 		 */
108
-		public function getAll(){
108
+		public function getAll() {
109 109
 			return $this->languages;
110 110
 		}
111 111
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		 * @param string $key the language key to identify
116 116
 		 * @param string $value the language message value
117 117
 		 */
118
-		public function set($key, $value){
118
+		public function set($key, $value) {
119 119
 			$this->languages[$key] = $value;
120 120
 		}
121 121
 
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 		 *
128 128
 		 * @return string the language message value
129 129
 		 */
130
-		public function get($key, $default = 'LANGUAGE_ERROR'){
131
-			if(isset($this->languages[$key])){
130
+		public function get($key, $default = 'LANGUAGE_ERROR') {
131
+			if (isset($this->languages[$key])) {
132 132
 				return $this->languages[$key];
133 133
 			}
134
-			$this->logger->warning('Language key  [' .$key. '] does not exist use the default value [' .$default. ']');
134
+			$this->logger->warning('Language key  [' . $key . '] does not exist use the default value [' . $default . ']');
135 135
 			return $default;
136 136
 		}
137 137
 
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
 		 *
143 143
 		 * @return boolean true if the language directory exists, false or not
144 144
 		 */
145
-		public function isValid($language){
145
+		public function isValid($language) {
146 146
 			$searchDir = array(CORE_LANG_PATH, APP_LANG_PATH);
147
-			foreach($searchDir as $dir){
148
-				if(file_exists($dir . $language) && is_dir($dir . $language)){
147
+			foreach ($searchDir as $dir) {
148
+				if (file_exists($dir . $language) && is_dir($dir . $language)) {
149 149
 					return true;
150 150
 				}
151 151
 			}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		 *
158 158
 		 * @return string the default language
159 159
 		 */
160
-		public function getDefault(){
160
+		public function getDefault() {
161 161
 			return $this->default;
162 162
 		}
163 163
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		 *
167 167
 		 * @return string the current language
168 168
 		 */
169
-		public function getCurrent(){
169
+		public function getCurrent() {
170 170
 			return $this->current;
171 171
 		}
172 172
 
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 		 * @param string $name the short language name like "en", "fr".
177 177
 		 * @param string $description the human readable description of this language
178 178
 		 */
179
-		public function addLang($name, $description){
180
-			if(isset($this->availables[$name])){
179
+		public function addLang($name, $description) {
180
+			if (isset($this->availables[$name])) {
181 181
 				return; //already added cost in performance
182 182
 			}
183
-			if($this->isValid($name)){
183
+			if ($this->isValid($name)) {
184 184
 				$this->availables[$name] = $description;
185 185
 			}
186
-			else{
186
+			else {
187 187
 				show_error('The language [' . $name . '] is not valid or does not exists.');
188 188
 			}
189 189
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		 *
194 194
 		 * @return array the list of the application language
195 195
 		 */
196
-		public function getSupported(){
196
+		public function getSupported() {
197 197
 			return $this->availables;
198 198
 		}
199 199
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		 *
203 203
 		 * @param array $langs the languages array of the messages to be added
204 204
 		 */
205
-		public function addLangMessages(array $langs){
205
+		public function addLangMessages(array $langs) {
206 206
 			foreach ($langs as $key => $value) {
207 207
 				$this->set($key, $value);
208 208
 			}
Please login to merge, or discard this patch.
core/classes/Controller.php 1 patch
Spacing   +13 added lines, -13 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{
27
+	class Controller {
28 28
 		
29 29
 		/**
30 30
 		 * The name of the module if this controller belong to an module
@@ -47,32 +47,32 @@  discard block
 block discarded – undo
47 47
 		/**
48 48
 		 * Class constructor
49 49
 		 */
50
-		public function __construct(){
51
-			$this->logger =& class_loader('Log', 'classes');
50
+		public function __construct() {
51
+			$this->logger = & class_loader('Log', 'classes');
52 52
 			$this->logger->setLogger('MainController');
53 53
 			self::$instance = & $this;
54 54
 			
55 55
 			$this->logger->debug('Adding the loaded classes to the super instance');
56
-			foreach (class_loaded() as $var => $class){
57
-				$this->$var =& class_loader($class);
56
+			foreach (class_loaded() as $var => $class) {
57
+				$this->$var = & class_loader($class);
58 58
 			}
59 59
 			
60 60
 			$this->logger->debug('Setting the cache handler instance');
61 61
 			//set cache handler instance
62
-			if(get_config('cache_enable', false)){
63
-				if(isset($this->{strtolower(get_config('cache_handler'))})){
62
+			if (get_config('cache_enable', false)) {
63
+				if (isset($this->{strtolower(get_config('cache_handler'))})) {
64 64
 					$this->cache = $this->{strtolower(get_config('cache_handler'))};
65 65
 					unset($this->{strtolower(get_config('cache_handler'))});
66 66
 				} 
67 67
 			}
68 68
 			$this->logger->debug('Loading the required classes into super instance');
69
-			$this->eventdispatcher =& class_loader('EventDispatcher', 'classes');
70
-			$this->loader =& class_loader('Loader', 'classes');
71
-			$this->lang =& class_loader('Lang', 'classes');
72
-			$this->request =& class_loader('Request', 'classes');
69
+			$this->eventdispatcher = & class_loader('EventDispatcher', 'classes');
70
+			$this->loader = & class_loader('Loader', 'classes');
71
+			$this->lang = & class_loader('Lang', 'classes');
72
+			$this->request = & class_loader('Request', 'classes');
73 73
 			//dispatch the request instance created event
74 74
 			$this->eventdispatcher->dispatch('REQUEST_CREATED');
75
-			$this->response =& class_loader('Response', 'classes', 'classes');
75
+			$this->response = & class_loader('Response', 'classes', 'classes');
76 76
 			
77 77
 			
78 78
 			//set session config
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			set_session_config();
81 81
 			
82 82
 			//determine the current module
83
-			if(isset($this->router) && $this->router->getModule()){
83
+			if (isset($this->router) && $this->router->getModule()) {
84 84
 				$this->moduleName = $this->router->getModule();
85 85
 			}
86 86
 			//dispatch the loaded instance of super controller event
Please login to merge, or discard this patch.
core/bootstrap.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	
43 43
 	//if the application is running in CLI mode $_SESSION global variable is not available
44
-	if(IS_CLI){
44
+	if (IS_CLI) {
45 45
 		$_SESSION = array();
46 46
 	}
47 47
 		
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * The Benchmark class
62 62
 	 */
63
-	$BENCHMARK =& class_loader('Benchmark');
63
+	$BENCHMARK = & class_loader('Benchmark');
64 64
 	
65 65
 	$BENCHMARK->mark('APP_EXECUTION_START');
66 66
 	
67 67
 	/**
68 68
     * instance of the Log class
69 69
     */
70
-    $LOGGER =& class_loader('Log', 'classes');
70
+    $LOGGER = & class_loader('Log', 'classes');
71 71
 
72 72
     $LOGGER->setLogger('ApplicationBootstrap');
73 73
 
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 	/**
77 77
 	* Verification of the PHP environment: minimum and maximum version
78 78
 	*/
79
-	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){
79
+	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')) {
80 80
 		show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment');	
81 81
 	}
82
-	else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){
82
+	else if (version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')) {
83 83
 		show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment');	
84 84
 	}
85 85
 	$LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue');
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	
102 102
 	//if user have some composer packages
103 103
 	$LOGGER->debug('Check for composer autoload');
104
-	if(file_exists(VENDOR_PATH . 'autoload.php')){
104
+	if (file_exists(VENDOR_PATH . 'autoload.php')) {
105 105
 		$LOGGER->info('The composer autoload file exists include it');
106 106
 		require_once VENDOR_PATH . 'autoload.php';
107 107
 	}
108
-	else{
108
+	else {
109 109
 		$LOGGER->info('The composer autoload file does not exist skipping');
110 110
 	}
111 111
 	
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	* Load configurations and using the 
122 122
 	* static method "init()" to initialize the Config class .
123 123
 	*/
124
-	$CONFIG =& class_loader('Config', 'classes');	
124
+	$CONFIG = & class_loader('Config', 'classes');	
125 125
 	$CONFIG->init();
126 126
 	$BENCHMARK->mark('CONFIG_INIT_END');
127 127
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	* Load modules and using the 
131 131
 	* static method "init()" to initialize the Module class.
132 132
 	*/
133
-	$MODULE =& class_loader('Module', 'classes');
133
+	$MODULE = & class_loader('Module', 'classes');
134 134
 	$MODULE->init();
135 135
 	$BENCHMARK->mark('MODULE_INIT_END');
136 136
 
@@ -149,34 +149,34 @@  discard block
 block discarded – undo
149 149
 	/**
150 150
 	* Loading Security class
151 151
 	*/
152
-	$SECURITY =& class_loader('Security', 'classes');
152
+	$SECURITY = & class_loader('Security', 'classes');
153 153
 	$SECURITY->checkWhiteListIpAccess();
154 154
 	
155 155
 	/**
156 156
 	* Loading Url class
157 157
 	*/
158
-	$URL =& class_loader('Url', 'classes');
158
+	$URL = & class_loader('Url', 'classes');
159 159
 	
160
-	if(get_config('cache_enable', false)){
160
+	if (get_config('cache_enable', false)) {
161 161
 		/**
162 162
 		 * Load Cache interface file
163 163
 		 */
164 164
 		require_once CORE_CLASSES_CACHE_PATH . 'CacheInterface.php';
165 165
 		$cacheHandler = get_config('cache_handler');
166
-		if(! $cacheHandler){
166
+		if (!$cacheHandler) {
167 167
 			show_error('The cache feature is enabled in the configuration but the cache handler class is not set.');
168 168
 		}
169 169
 		$CACHE = null;
170 170
 		//first check if the cache handler is the system driver
171
-		if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){
172
-			$CACHE =& class_loader($cacheHandler, 'classes/cache');
171
+		if (file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')) {
172
+			$CACHE = & class_loader($cacheHandler, 'classes/cache');
173 173
 		}
174
-		else{
174
+		else {
175 175
 			//it's not a system driver use user library
176
-			$CACHE =& class_loader($cacheHandler);
176
+			$CACHE = & class_loader($cacheHandler);
177 177
 		}
178 178
 		//check if the page already cached
179
-		if(! empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get'){
179
+		if (!empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get') {
180 180
 			$RESPONSE = & class_loader('Response', 'classes');
181 181
 			$RESPONSE->renderFinalPageFromCache($CACHE);
182 182
 		}
Please login to merge, or discard this patch.
tests/hmvc/models/DBSessionModel.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	class DBSessionModel extends DBSessionHandlerModel{
2
+	class DBSessionModel extends DBSessionHandlerModel {
3 3
 		
4 4
 		protected $_table = 'ses';
5 5
 		protected $primary_key = 's_id';
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
 			'skey' => 'test_id' //VARCHAR(255) 
15 15
 		);
16 16
 		
17
-		public function deleteByTime($time){
17
+		public function deleteByTime($time) {
18 18
 			$this->_database->from($this->_table)
19 19
 						->where('s_time', '<', $time)
20 20
 						->delete();
21 21
 		}
22 22
 
23 23
 		
24
-		public function getKeyValue(){
24
+		public function getKeyValue() {
25 25
 			$user_id = 0;
26 26
 			return $user_id;
27 27
 		}
Please login to merge, or discard this patch.
tests/include/common.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 		//put the first letter of class to upper case 
30 30
 		$class = ucfirst($class);
31 31
 		static $classes = array();
32
-		if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){
32
+		if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log') {
33 33
 			return $classes[$class];
34 34
 		}
35 35
 		$found = false;
36 36
 		foreach (array(ROOT_PATH, CORE_PATH) as $path) {
37 37
 			$file = $path . $dir . '/' . $class . '.php';
38
-			if(file_exists($file)){
39
-				if(class_exists($class, false) == false){
38
+			if (file_exists($file)) {
39
+				if (class_exists($class, false) == false) {
40 40
 					require_once $file;
41 41
 				}
42 42
 				//already found
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 				break;
45 45
 			}
46 46
 		}
47
-		if(! $found){
47
+		if (!$found) {
48 48
 			//can't use show_error() at this time because some dependencies not yet loaded
49 49
 			set_http_status_header(503);
50 50
 			echo 'Cannot find the class [' . $class . ']';
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		/*
55 55
 		   TODO use the best method to get the Log instance
56 56
 		 */
57
-		if($class == 'Log'){
57
+		if ($class == 'Log') {
58 58
 			//can't use the instruction like "return new Log()" 
59 59
 			//because we need return the reference instance of the loaded class.
60 60
 			$log = new Log();
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	function & class_loaded($class = null){
74 74
 		static $list = array();
75
-		if($class != null){
75
+		if ($class != null) {
76 76
 			$list[strtolower($class)] = $class;
77 77
 		}
78 78
 		return $list;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
 	function & load_configurations(array $overwrite_values = array()){
82 82
 		static $config;
83
-		if(empty($config)){
83
+		if (empty($config)) {
84 84
 			$file = CONFIG_PATH . 'config.php';
85 85
 			require_once $file;
86 86
 		
@@ -94,50 +94,50 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	*  @test
96 96
 	*/
97
-	function get_config($key, $default = null){
97
+	function get_config($key, $default = null) {
98 98
 		static $cfg;
99
-		if(empty($cfg)){
99
+		if (empty($cfg)) {
100 100
 			$cfg[0] = & load_configurations();
101 101
 		}
102 102
 		return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default;
103 103
 	}
104 104
 
105
-	function save_to_log($level, $message, $logger = null){
105
+	function save_to_log($level, $message, $logger = null) {
106 106
 		return true;
107 107
 	}
108 108
 
109 109
 	
110
-	function set_http_status_header($code = 200, $text = null){
110
+	function set_http_status_header($code = 200, $text = null) {
111 111
 		return true;
112 112
 	}
113 113
 
114 114
 	
115
-	function show_error($msg, $title = 'error', $logging = true){
115
+	function show_error($msg, $title = 'error', $logging = true) {
116 116
 		//show only and continue to help track of some error occured
117
-		echo 'TNHFW Error: '.$msg . "\n";
117
+		echo 'TNHFW Error: ' . $msg . "\n";
118 118
 	}
119 119
 
120
-	function is_https(){
120
+	function is_https() {
121 121
 		return false;
122 122
 	}
123 123
 	
124 124
 	/**
125 125
 	*  @test
126 126
 	*/
127
-	function is_url($url){
127
+	function is_url($url) {
128 128
 		return preg_match('/^(http|https|ftp):\/\/(.*)/', $url);
129 129
 	}
130 130
 		
131
-	function php_exception_handler($ex){
132
-		throw new RuntimeException('PHP Exception : '.$ex->getMessage().' | '.$ex->getFile().' | '.$ex->getLine());
131
+	function php_exception_handler($ex) {
132
+		throw new RuntimeException('PHP Exception : ' . $ex->getMessage() . ' | ' . $ex->getFile() . ' | ' . $ex->getLine());
133 133
 	}
134 134
 	
135 135
 	
136
-	function php_error_handler($errno , $errstr, $errfile , $errline, array $errcontext = array()){
137
-		throw new RuntimeException('TNHFW Exception Error : '.$errstr.' | '.$errfile.' | '.$errline);
136
+	function php_error_handler($errno, $errstr, $errfile, $errline, array $errcontext = array()) {
137
+		throw new RuntimeException('TNHFW Exception Error : ' . $errstr . ' | ' . $errfile . ' | ' . $errline);
138 138
 	}
139 139
 
140
-	function php_shudown_handler(){
140
+	function php_shudown_handler() {
141 141
 		return true;
142 142
 	}
143 143
 
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 	/**
146 146
 	*  @test
147 147
 	*/
148
-	function attributes_to_string(array $attributes){
148
+	function attributes_to_string(array $attributes) {
149 149
 		$str = ' ';
150 150
 		//we check that the array passed as an argument is not empty.
151
-		if(! empty($attributes)){
152
-			foreach($attributes as $key => $value){
151
+		if (!empty($attributes)) {
152
+			foreach ($attributes as $key => $value) {
153 153
 				$key = trim(htmlspecialchars($key));
154 154
 				$value = trim(htmlspecialchars($value));
155 155
 				/*
@@ -159,35 +159,35 @@  discard block
 block discarded – undo
159 159
 				* 	$attr = array('placeholder' => 'I am a "puple"')
160 160
 				* 	$str = attributes_to_string($attr); => placeholder = "I am a \"puple\""
161 161
 				 */
162
-				if($value && strpos('"', $value) !== false){
162
+				if ($value && strpos('"', $value) !== false) {
163 163
 					$value = addslashes($value);
164 164
 				}
165
-				$str .= $key.' = "'.$value.'" ';
165
+				$str .= $key . ' = "' . $value . '" ';
166 166
 			}
167 167
 		}
168 168
 		//remove the space after using rtrim()
169 169
 		return rtrim($str);
170 170
 	}
171 171
 
172
-	function stringfy_vars($var){
172
+	function stringfy_vars($var) {
173 173
 		return print_r($var, true);
174 174
 	}
175 175
 
176 176
 	/**
177 177
 	*  @test
178 178
 	*/
179
-	function clean_input($str){
180
-		if(is_array($str)){
179
+	function clean_input($str) {
180
+		if (is_array($str)) {
181 181
 			$str = array_map('clean_input', $str);
182 182
 		}
183
-		else if(is_object($str)){
183
+		else if (is_object($str)) {
184 184
 			$obj = $str;
185 185
 			foreach ($str as $var => $value) {
186 186
 				$obj->$var = clean_input($value);
187 187
 			}
188 188
 			$str = $obj;
189 189
 		}
190
-		else{
190
+		else {
191 191
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
192 192
 		}
193 193
 		return $str;
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 	/**
197 197
 	*  @test
198 198
 	*/
199
-	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
199
+	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') {
200 200
 		//get the string length
201 201
 		$len = strlen($str);
202 202
 		//if str is empty
203
-		if($len <= 0){
203
+		if ($len <= 0) {
204 204
 			return str_repeat($hiddenChar, 6);
205 205
 		}
206 206
 		//if the length is less than startCount and endCount
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 		//or startCount is negative or endCount is negative
209 209
 		//return the full string hidden
210 210
 		
211
-		if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
211
+		if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) {
212 212
 			return str_repeat($hiddenChar, $len);
213 213
 		}
214 214
 		//the start non hidden string
215 215
 		$startNonHiddenStr = substr($str, 0, $startCount);
216 216
 		//the end non hidden string
217 217
 		$endNonHiddenStr = null;
218
-		if($endCount > 0){
218
+		if ($endCount > 0) {
219 219
 			$endNonHiddenStr = substr($str, - $endCount);
220 220
 		}
221 221
 		//the hidden string
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
 		return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr;
225 225
 	}
226 226
 	
227
-	function set_session_config(){
227
+	function set_session_config() {
228 228
 		return true;
229 229
 	}
230 230
 	
231 231
 	function & get_instance(){
232
-		if(! Controller::get_instance()){
232
+		if (!Controller::get_instance()) {
233 233
 			$c = new Controller();
234 234
 		}
235 235
 		return Controller::get_instance();
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	* Custom application path for tests 
62 62
 	*/
63
-	define('APPS_PATH', TESTS_PATH .'hmvc' . DS);
63
+	define('APPS_PATH', TESTS_PATH . 'hmvc' . DS);
64 64
 
65 65
 	/**
66 66
 	* The path to the controller directory of your application.
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	* It contains your modules used files (config, controllers, libraries, etc.) that is to say which contains your files of the modules, 
197 197
 	* in HMVC architecture (hierichical, controllers, models, views).
198 198
 	*/
199
-	define('MODULE_PATH', dirname(realpath(__FILE__)) . DS .'hmvc' . DS . 'modules' . DS);
199
+	define('MODULE_PATH', dirname(realpath(__FILE__)) . DS . 'hmvc' . DS . 'modules' . DS);
200 200
 
201 201
 	/**
202 202
 	* The path to the directory of sources external to your application.
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	//Fix to allow test as if application is running in CLI mode $_SESSION global variable is not available
236 236
 	$_SESSION = array();
237 237
 	
238
-	if(! isset($_SERVER['REMOTE_ADDR'])){ 
238
+	if (!isset($_SERVER['REMOTE_ADDR'])) { 
239 239
 		$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
240 240
 	}
241 241
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	require_once  'include/autoloader.php';
244 244
 	
245 245
 	//check for composer autoload file if exists include it
246
-	if(file_exists(VENDOR_PATH . 'autoload.php')){
246
+	if (file_exists(VENDOR_PATH . 'autoload.php')) {
247 247
 		require_once VENDOR_PATH . 'autoload.php';
248 248
 		
249 249
 		//define the class alias for vstream
Please login to merge, or discard this patch.
tests/tnhfw/CommonTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@
 block discarded – undo
24 24
 		}
25 25
 
26 26
 		
27
-		public function testFunctionGetConfigKeyNotExist(){
27
+		public function testFunctionGetConfigKeyNotExist() {
28 28
 			$key = 'foo';
29 29
 			$cfg = get_config($key);
30 30
 			$this->assertNull($cfg);
31 31
 		}
32 32
 		
33
-		public function testFunctionGetConfigKeyNotExistUsingDefaultValue(){
33
+		public function testFunctionGetConfigKeyNotExistUsingDefaultValue() {
34 34
 			$key = 'foo';
35 35
 			$expected = 'bar';
36 36
 			$cfg = get_config($key, $expected);
37 37
 			$this->assertEquals($cfg, $expected);
38 38
 		}
39 39
 		
40
-		public function testFunctionGetConfigAfterSet(){
40
+		public function testFunctionGetConfigAfterSet() {
41 41
 			$key = 'foo';
42 42
 			$expected = 'bar';
43 43
 			$c = new Config();
Please login to merge, or discard this patch.