Passed
Branch 1.0.0-dev (c78053)
by nguereza
04:10 queued 15s
created
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/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.
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) === true;
116 116
 			}
117 117
 		}
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 		 * 'expire' => expiration time of the cache (Unix timestamp),
125 125
 		 * 'ttl' => the time to live of the cache in second
126 126
 		 */
127
-		public function getInfo($key){
128
-			$this->logger->debug('Getting of cache info for key [' .$key. ']');
127
+		public function getInfo($key) {
128
+			$this->logger->debug('Getting of cache info for key [' . $key . ']');
129 129
 			$cacheInfos = $this->_getCacheInfo($key);
130
-			if($cacheInfos){
130
+			if ($cacheInfos) {
131 131
 				$data = array(
132 132
 							'mtime' => $cacheInfos['creation_time'],
133 133
 							'expire' => $cacheInfos['creation_time'] + $cacheInfos['ttl'],
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 							);
136 136
 				return $data;
137 137
 			}
138
-			else{
138
+			else {
139 139
 				$this->logger->info('This cache does not exists skipping');
140 140
 				return false;
141 141
 			}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		/**
146 146
 		 * Used to delete expired cache data
147 147
 		 */
148
-		public function deleteExpiredCache(){
148
+		public function deleteExpiredCache() {
149 149
 			//for APC[u] is done automatically
150 150
 			return true;
151 151
 		}
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 		/**
154 154
 		 * Remove all cache data
155 155
 		 */
156
-		public function clean(){
156
+		public function clean() {
157 157
 			$this->logger->debug('Deleting of all cache data');
158 158
 			$cacheInfos = apc_cache_info('user');
159
-			if(empty($cacheInfos['cache_list'])){
159
+			if (empty($cacheInfos['cache_list'])) {
160 160
 				$this->logger->info('No cache data were found skipping');
161 161
 				return false;
162 162
 			}
163
-			else{
163
+			else {
164 164
 				$this->logger->info('Found [' . count($cacheInfos) . '] cache data to remove');
165 165
 				return apc_clear_cache('user');
166 166
 			}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		 *
173 173
 		 * @return bool
174 174
 		 */
175
-		public function isSupported(){
175
+		public function isSupported() {
176 176
 			return (extension_loaded('apc') || extension_loaded('apcu')) && ini_get('apc.enabled');
177 177
 		}
178 178
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	     * Return the Log instance
181 181
 	     * @return Log
182 182
 	     */
183
-	    public function getLogger(){
183
+	    public function getLogger() {
184 184
 	      return $this->logger;
185 185
 	    }
186 186
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	     * Set the log instance
189 189
 	     * @param Log $logger the log object
190 190
 	     */
191
-	    public function setLogger(Log $logger){
191
+	    public function setLogger(Log $logger) {
192 192
 	      $this->logger = $logger;
193 193
 	      return $this;
194 194
 	    }
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
 		* @param string $key the cache key to get the cache information 
200 200
 		* @return boolean|array
201 201
 		*/
202
-		private function _getCacheInfo($key){
202
+		private function _getCacheInfo($key) {
203 203
 			$caches = apc_cache_info('user');
204
-			if(! empty($caches['cache_list'])){
204
+			if (!empty($caches['cache_list'])) {
205 205
 				$cacheLists = $caches['cache_list'];
206
-				foreach ($cacheLists as $c){
207
-					if(isset($c['info']) && $c['info'] === $key){
206
+				foreach ($cacheLists as $c) {
207
+					if (isset($c['info']) && $c['info'] === $key) {
208 208
 						return $c;
209 209
 					}
210 210
 				}
Please login to merge, or discard this patch.
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(! is_resource($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 (!is_resource($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
 		}
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 		 * @param integer $ttl  the cache life time
111 111
 		 * @return boolean true if success otherwise will return false
112 112
 		 */
113
-		public function set($key, $data, $ttl = 0){
113
+		public function set($key, $data, $ttl = 0) {
114 114
 			$expire = time() + $ttl;
115
-			$this->logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
115
+			$this->logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
116 116
 			$filePath = $this->getFilePath($key);
117
-			$handle = fopen($filePath,'w');
118
-			if(! is_resource($handle)){
119
-				$this->logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
117
+			$handle = fopen($filePath, 'w');
118
+			if (!is_resource($handle)) {
119
+				$this->logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
120 120
 				return false;
121 121
 			}
122 122
 			flock($handle, LOCK_EX); // exclusive lock, will get released when the file is closed
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 									)
130 130
 								);		   
131 131
 		    $result = fwrite($handle, $this->compressCacheData ? gzdeflate($cacheData, 9) : $cacheData);
132
-		    if(! $result){
133
-		    	$this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
132
+		    if (!$result) {
133
+		    	$this->logger->error('Can not write cache data into file [' . $filePath . '] for the key [' . $key . '], return false');
134 134
 		    	fclose($handle);
135 135
 		    	return false;
136 136
 		    }
137
-		    else{
138
-		    	$this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
137
+		    else {
138
+		    	$this->logger->info('Cache data saved into file [' . $filePath . '] for the key [' . $key . ']');
139 139
 		    	fclose($handle);
140 140
 				chmod($filePath, 0640);
141 141
 				return true;
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 		 * @return boolean      true if the cache is delete, false if can't delete 
150 150
 		 * the cache or the cache with the given key not exist
151 151
 		 */
152
-		public function delete($key){
153
-			$this->logger->debug('Deleting of cache data for key [' .$key. ']');
152
+		public function delete($key) {
153
+			$this->logger->debug('Deleting of cache data for key [' . $key . ']');
154 154
 			$filePath = $this->getFilePath($key);
155
-			$this->logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
156
-			if(! file_exists($filePath)){
155
+			$this->logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
156
+			if (!file_exists($filePath)) {
157 157
 				$this->logger->info('This cache file does not exists skipping');
158 158
 				return false;
159 159
 			}
160
-			else{
161
-				$this->logger->info('Found cache file [' .$filePath. '] remove it');
160
+			else {
161
+				$this->logger->info('Found cache file [' . $filePath . '] remove it');
162 162
 	      		unlink($filePath);
163 163
 				return true;
164 164
 			}
@@ -172,25 +172,25 @@  discard block
 block discarded – undo
172 172
 		 * 'expire' => expiration time of the cache (Unix timestamp),
173 173
 		 * 'ttl' => the time to live of the cache in second
174 174
 		 */
175
-		public function getInfo($key){
176
-			$this->logger->debug('Getting of cache info for key [' .$key. ']');
175
+		public function getInfo($key) {
176
+			$this->logger->debug('Getting of cache info for key [' . $key . ']');
177 177
 			$filePath = $this->getFilePath($key);
178
-			$this->logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
179
-			if(! file_exists($filePath)){
178
+			$this->logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
179
+			if (!file_exists($filePath)) {
180 180
 				$this->logger->info('This cache file does not exists skipping');
181 181
 				return false;
182 182
 			}
183
-			else{
184
-				$this->logger->info('Found cache file [' .$filePath. '] check the validity');
183
+			else {
184
+				$this->logger->info('Found cache file [' . $filePath . '] check the validity');
185 185
 	      		$data = file_get_contents($filePath);
186 186
 				$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
187
-				if(! $data){
187
+				if (!$data) {
188 188
 					$this->logger->warning('Can not unserialize the cache data for file [' . $filePath . ']');
189 189
 					return false;
190 190
 				}
191
-				else{
191
+				else {
192 192
 					$this->logger->info('This cache data is OK check for expire');
193
-					if(isset($data['expire']) && $data['expire'] > time()){
193
+					if (isset($data['expire']) && $data['expire'] > time()) {
194 194
 						$this->logger->info('This cache not yet expired return cache informations');
195 195
 						$info = array(
196 196
 							'mtime' => $data['mtime'],
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 							);
200 200
 						return $info;
201 201
 					}
202
-					else{
202
+					else {
203 203
 						$this->logger->info('This cache already expired return false');
204 204
 						return false;
205 205
 					}
@@ -211,26 +211,26 @@  discard block
 block discarded – undo
211 211
 		/**
212 212
 		 * Used to delete expired cache data
213 213
 		 */
214
-		public function deleteExpiredCache(){
214
+		public function deleteExpiredCache() {
215 215
 			$this->logger->debug('Deleting of expired cache files');
216 216
 			$list = glob(CACHE_PATH . '*.cache');
217
-			if(! $list){
217
+			if (!$list) {
218 218
 				$this->logger->info('No cache files were found skipping');
219 219
 			}
220
-			else{
220
+			else {
221 221
 				$this->logger->info('Found [' . count($list) . '] cache files to remove if expired');
222 222
 				foreach ($list as $file) {
223 223
 					$this->logger->debug('Processing the cache file [' . $file . ']');
224 224
 					$data = file_get_contents($file);
225 225
 		      		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
226
-		      		if(! $data){
226
+		      		if (!$data) {
227 227
 		      			$this->logger->warning('Can not unserialize the cache data for file [' . $file . ']');
228 228
 		      		}
229
-		      		else if(time() > $data['expire']){
229
+		      		else if (time() > $data['expire']) {
230 230
 		      			$this->logger->info('The cache data for file [' . $file . '] already expired remove it');
231 231
 		      			unlink($file);
232 232
 		      		}
233
-		      		else{
233
+		      		else {
234 234
 		      			$this->logger->info('The cache data for file [' . $file . '] not yet expired skip it');
235 235
 		      		}
236 236
 				}
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 		/**
241 241
 		 * Remove all file from cache folder
242 242
 		 */
243
-		public function clean(){
243
+		public function clean() {
244 244
 			$this->logger->debug('Deleting of all cache files');
245 245
 			$list = glob(CACHE_PATH . '*.cache');
246
-			if(! $list){
246
+			if (!$list) {
247 247
 				$this->logger->info('No cache files were found skipping');
248 248
 			}
249
-			else{
249
+			else {
250 250
 				$this->logger->info('Found [' . count($list) . '] cache files to remove');
251 251
 				foreach ($list as $file) {
252 252
 					$this->logger->debug('Processing the cache file [' . $file . ']');
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	    /**
259 259
 	     * @return boolean
260 260
 	     */
261
-	    public function isCompressCacheData(){
261
+	    public function isCompressCacheData() {
262 262
 	        return $this->compressCacheData;
263 263
 	    }
264 264
 
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
 	     *
268 268
 	     * @return self
269 269
 	     */
270
-	    public function setCompressCacheData($status = true){
270
+	    public function setCompressCacheData($status = true) {
271 271
 			//if Zlib extension is not loaded set compressCacheData to false
272
-			if($status === true && ! extension_loaded('zlib')){
272
+			if ($status === true && !extension_loaded('zlib')) {
273 273
 				
274 274
 				$this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
275 275
 				$this->compressCacheData = false;
276 276
 			}
277
-			else{
277
+			else {
278 278
 				$this->compressCacheData = $status;
279 279
 			}
280 280
 			return $this;
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		 *
286 286
 		 * @return bool
287 287
 		 */
288
-		public function isSupported(){
288
+		public function isSupported() {
289 289
 			return CACHE_PATH && is_dir(CACHE_PATH) && is_writable(CACHE_PATH);
290 290
 		}
291 291
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	     * Return the Log instance
294 294
 	     * @return Log
295 295
 	     */
296
-	    public function getLogger(){
296
+	    public function getLogger() {
297 297
 	      return $this->logger;
298 298
 	    }
299 299
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	     * Set the log instance
302 302
 	     * @param Log $logger the log object
303 303
 	     */
304
-	    public function setLogger(Log $logger){
304
+	    public function setLogger(Log $logger) {
305 305
 	      $this->logger = $logger;
306 306
 	      return $this;
307 307
 	    }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		* @param $key the cache item key
313 313
 		* @return string the full cache file path for this key
314 314
 		*/
315
-		private function getFilePath($key){
315
+		private function getFilePath($key) {
316 316
 			return CACHE_PATH . md5($key) . '.cache';
317 317
 		}
318 318
 	}
Please login to merge, or discard this patch.
tests/tnhfw/classes/DBSessionHandlerTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 		
14 14
 		private static $config = null;
15 15
 		
16
-		public function __construct(){
16
+		public function __construct() {
17 17
 			$this->db = new Database(array(
18 18
 								'driver'    =>  'sqlite',
19 19
 								'database'  =>  TESTS_PATH . 'assets/db_tests.db',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 		
51 51
 		
52
-		public function testUsingSessionConfiguration(){
52
+		public function testUsingSessionConfiguration() {
53 53
 			//using value in the configuration
54 54
 			static::$config->set('session_save_path', 'DBSessionModel');
55 55
 			static::$config->set('session_secret', $this->secret);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			$this->assertEquals($dbsh->decode($encoded), 'foo');
76 76
 		}
77 77
 		
78
-		public function testWhenDataIsExpired(){
78
+		public function testWhenDataIsExpired() {
79 79
 			$dbsh = new DBSessionHandler($this->model);
80 80
 			$dbsh->setSessionSecret($this->secret);
81 81
 			
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			$this->assertNull($dbsh->read('foo'));
89 89
 		}
90 90
 		
91
-		public function testWhenDataAlreadyExistDoUpdate(){
91
+		public function testWhenDataAlreadyExistDoUpdate() {
92 92
 			$dbsh = new DBSessionHandler($this->model);
93 93
 			$dbsh->setSessionSecret($this->secret);
94 94
 			
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			$this->assertEquals($dbsh->read('foo'), '445');	
102 102
 		}
103 103
 		
104
-		public function testUsingCustomModelInstance(){
104
+		public function testUsingCustomModelInstance() {
105 105
 			$dbsh = new DBSessionHandler($this->model);
106 106
 			$dbsh->setSessionSecret($this->secret);
107 107
 			
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		}
130 130
 			
131 131
 			
132
-		public function testUsingCustomLogInstance(){
132
+		public function testUsingCustomLogInstance() {
133 133
 			$dbsh = new DBSessionHandler($this->model, new Log());
134 134
 			$dbsh->setSessionSecret($this->secret);
135 135
 			
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			$this->assertEquals($dbsh->decode($encoded), 'foo');
157 157
 		}
158 158
 		
159
-		public function testUsingCustomLoaderInstance(){
159
+		public function testUsingCustomLoaderInstance() {
160 160
 			$dbsh = new DBSessionHandler($this->model, null, new Loader());
161 161
 			$dbsh->setSessionSecret($this->secret);
162 162
 			
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		}
185 185
 		
186 186
 		
187
-		public function testWhenModelInsanceIsNotSet(){
187
+		public function testWhenModelInsanceIsNotSet() {
188 188
 			$dbsh = new DBSessionHandler(null, null, new Loader());
189 189
 			$dbsh->setSessionSecret($this->secret);
190 190
 			
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 			$this->assertEquals($dbsh->decode($encoded), 'foo');
213 213
 		}
214 214
 		
215
-		public function testWhenModelTableColumnsIsNotSet(){
215
+		public function testWhenModelTableColumnsIsNotSet() {
216 216
 			//session table is empty
217 217
 			$this->model->setSessionTableColumns(array());
218 218
 			$dbsh = new DBSessionHandler($this->model);
Please login to merge, or discard this patch.
core/libraries/Cookie.php 1 patch
Spacing   +15 added lines, -15 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 Cookie{
27
+	class Cookie {
28 28
 		
29 29
 		/**
30 30
 		 * The logger instance
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 		 * The signleton of the logger
37 37
 		 * @return Object the Log instance
38 38
 		 */
39
-		private static function getLogger(){
40
-			if(self::$logger == null){
41
-				self::$logger[0] =& class_loader('Log', 'classes');
39
+		private static function getLogger() {
40
+			if (self::$logger == null) {
41
+				self::$logger[0] = & class_loader('Log', 'classes');
42 42
 				self::$logger[0]->setLogger('Library::Cookie');
43 43
 			}
44 44
 			return self::$logger[0];
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 		 * @param  mixed $default the default value to use if can not find the cokkie item in the list
51 51
 		 * @return mixed          the cookie value if exist or the default value
52 52
 		 */
53
-		public static function get($item, $default = null){
53
+		public static function get($item, $default = null) {
54 54
 			$logger = self::getLogger();
55
-			if(array_key_exists($item, $_COOKIE)){
55
+			if (array_key_exists($item, $_COOKIE)) {
56 56
 				return $_COOKIE[$item];
57 57
 			}
58 58
 			$logger->warning('Cannot find cookie item [' . $item . '], using the default value [' . $default . ']');
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 		 * @param boolean $secure   if this cookie will be available on secure connection or not
70 70
 		 * @param boolean $httponly if this cookie will be available under HTTP protocol.
71 71
 		 */
72
-		public static function set($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false){
73
-			if(headers_sent()){
72
+		public static function set($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false) {
73
+			if (headers_sent()) {
74 74
 				show_error('There exists a cookie that we wanted to create that we couldn\'t 
75 75
 						    because headers was already sent. Make sure to do this first 
76 76
 							before outputing anything.');
77 77
 			}
78 78
 			$timestamp = $expire;
79
-			if($expire){
79
+			if ($expire) {
80 80
 				$timestamp = time() + $expire;
81 81
 			}
82 82
 			setcookie($name, $value, $timestamp, $path, $domain, $secure, $httponly);
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 		 * @param  string $item the cookie item name to be cleared
88 88
 		 * @return boolean true if the item exists and is deleted successfully otherwise will return false.
89 89
 		 */
90
-		public static function delete($item){
90
+		public static function delete($item) {
91 91
 			$logger = self::getLogger();
92
-			if(array_key_exists($item, $_COOKIE)){
93
-				$logger->info('Delete cookie item ['.$item.']');
92
+			if (array_key_exists($item, $_COOKIE)) {
93
+				$logger->info('Delete cookie item [' . $item . ']');
94 94
 				unset($_COOKIE[$item]);
95 95
 				return true;
96 96
 			}
97
-			else{
98
-				$logger->warning('Cookie item ['.$item.'] to be deleted does not exists');
97
+			else {
98
+				$logger->warning('Cookie item [' . $item . '] to be deleted does not exists');
99 99
 				return false;
100 100
 			}
101 101
 		}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		 * @param  string $item the cookie item name
106 106
 		 * @return boolean       true if the cookie item is set, false or not
107 107
 		 */
108
-		public static function exists($item){
108
+		public static function exists($item) {
109 109
 			return array_key_exists($item, $_COOKIE);
110 110
 		}
111 111
 
Please login to merge, or discard this patch.
core/libraries/Assets.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *  @since 1.0.0
39 39
 	 *  @filesource
40 40
 	 */
41
-	class Assets{
41
+	class Assets {
42 42
 		
43 43
 		/**
44 44
 		 * The logger instance
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 		 * The signleton of the logger
51 51
 		 * @return Object the Log instance
52 52
 		 */
53
-		private static function getLogger(){
54
-			if(self::$logger == null){
53
+		private static function getLogger() {
54
+			if (self::$logger == null) {
55 55
 				//can't assign reference to static variable
56
-				self::$logger[0] =& class_loader('Log', 'classes');
56
+				self::$logger[0] = & class_loader('Log', 'classes');
57 57
 				self::$logger[0]->setLogger('Library::Assets');
58 58
 			}
59 59
 			return self::$logger[0];
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 		 *  @param $asset the name of the assets file path with the extension.
73 73
 		 *  @return string|null the absolute path of the assets file, if it exists otherwise returns null if the file does not exist.
74 74
 		 */
75
-		public static function path($asset){
75
+		public static function path($asset) {
76 76
 			$logger = self::getLogger();	
77 77
 			$path = ASSETS_PATH . $asset;
78 78
 			
79 79
 			$logger->debug('Including the Assets file [' . $path . ']');
80 80
 			//Check if the file exists
81
-			if(file_exists($path)){
81
+			if (file_exists($path)) {
82 82
 				$logger->info('Assets file [' . $path . '] included successfully');
83 83
 				return Url::base_url($path);
84 84
 			}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		 *  @param $path the name of the css file without the extension.
99 99
 		 *  @return string|null the absolute path of the css file, if it exists otherwise returns null if the file does not exist.
100 100
 		 */
101
-		public static function css($path){
101
+		public static function css($path) {
102 102
 			$logger = self::getLogger();
103 103
 			/*
104 104
 			* if the file name contains the ".css" extension, replace it with 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			
110 110
 			$logger->debug('Including the Assets file [' . $path . '] for CSS');
111 111
 			//Check if the file exists
112
-			if(file_exists($path)){
112
+			if (file_exists($path)) {
113 113
 				$logger->info('Assets file [' . $path . '] for CSS included successfully');
114 114
 				return Url::base_url($path);
115 115
 			}
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 		 *  @param $path the name of the javascript file without the extension.
130 130
 		 *  @return string|null the absolute path of the javascript file, if it exists otherwise returns null if the file does not exist.
131 131
 		 */
132
-		public static function js($path){
132
+		public static function js($path) {
133 133
 			$logger = self::getLogger();
134 134
 			$path = str_ireplace('.js', '', $path);
135 135
 			$path = ASSETS_PATH . 'js/' . $path . '.js';
136 136
 			$logger->debug('Including the Assets file [' . $path . '] for javascript');
137
-			if(file_exists($path)){
137
+			if (file_exists($path)) {
138 138
 				$logger->info('Assets file [' . $path . '] for Javascript included successfully');
139 139
 				return Url::base_url($path);
140 140
 			}
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 		 *  @param $path the name of the image file with the extension.
155 155
 		 *  @return string|null the absolute path of the image file, if it exists otherwise returns null if the file does not exist.
156 156
 		 */
157
-		public static function img($path){
157
+		public static function img($path) {
158 158
 			$logger = self::getLogger();
159 159
 			$path = ASSETS_PATH . 'images/' . $path;
160 160
 			$logger->debug('Including the Assets file [' . $path . '] for image');
161
-			if(file_exists($path)){
161
+			if (file_exists($path)) {
162 162
 				$logger->info('Assets file [' . $path . '] for image included successfully');
163 163
 				return Url::base_url($path);
164 164
 			}
Please login to merge, or discard this patch.
core/libraries/Benchmark.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * Class for Benchmark
29 29
 	 */
30
-	class Benchmark{
30
+	class Benchmark {
31 31
 		/**
32 32
 		 * The markers for excution time
33 33
 		 * @var array
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		 * This method is used to mark one point for benchmark (execution time and memory usage)
45 45
 		 * @param  string $name the marker name
46 46
 		 */
47
-		public function mark($name){
47
+		public function mark($name) {
48 48
 			//Marker for execution time
49 49
 			$this->markersTime[$name] = microtime(true);
50 50
 			//Marker for memory usage
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 		 * @param  integer $decimalCount   the number of decimal
59 59
 		 * @return string         the total execution time
60 60
 		 */
61
-		public function elapsedTime($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){
62
-			if(! $startMarkerName || !isset($this->markersTime[$startMarkerName])){
61
+		public function elapsedTime($startMarkerName = null, $endMarkerName = null, $decimalCount = 6) {
62
+			if (!$startMarkerName || !isset($this->markersTime[$startMarkerName])) {
63 63
 				return 0;
64 64
 			}
65 65
 			
66
-			if(! isset($this->markersTime[$endMarkerName])){
66
+			if (!isset($this->markersTime[$endMarkerName])) {
67 67
 				$this->markersTime[$endMarkerName] = microtime(true);
68 68
 			}
69 69
 			return number_format($this->markersTime[$endMarkerName] - $this->markersTime[$startMarkerName], $decimalCount);
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 		 * @param  integer $decimalCount   the number of decimal
77 77
 		 * @return string         the total memory usage
78 78
 		 */
79
-		public function memoryUsage($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){
80
-			if(! $startMarkerName || !isset($this->markersMemory[$startMarkerName])){
79
+		public function memoryUsage($startMarkerName = null, $endMarkerName = null, $decimalCount = 6) {
80
+			if (!$startMarkerName || !isset($this->markersMemory[$startMarkerName])) {
81 81
 				return 0;
82 82
 			}
83 83
 			
84
-			if(! isset($this->markersMemory[$endMarkerName])){
84
+			if (!isset($this->markersMemory[$endMarkerName])) {
85 85
 				$this->markersMemory[$endMarkerName] = microtime(true);
86 86
 			}
87 87
 			return number_format($this->markersMemory[$endMarkerName] - $this->markersMemory[$startMarkerName], $decimalCount);
Please login to merge, or discard this patch.