Test Failed
Push — 1.0.0-dev ( c7a39c...6c2ad2 )
by nguereza
03:29
created
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,52 +94,52 @@  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){
131
+	function php_exception_handler($ex) {
132 132
 		//show only and continue to help track of some error occured
133
-		echo 'TNHFW PHP Exception : '.$ex->getMessage().' | '.$ex->getFile().' | '.$ex->getLine();
133
+		echo 'TNHFW PHP Exception : ' . $ex->getMessage() . ' | ' . $ex->getFile() . ' | ' . $ex->getLine();
134 134
 	}
135 135
 	
136 136
 	
137
-	function php_error_handler($errno , $errstr, $errfile , $errline, array $errcontext = array()){
137
+	function php_error_handler($errno, $errstr, $errfile, $errline, array $errcontext = array()) {
138 138
 		//show only and continue to help track of some error occured
139
-		echo 'TNHFW PHP Error : '.$errstr.' | '.$errfile.' | '.$errline;
139
+		echo 'TNHFW PHP Error : ' . $errstr . ' | ' . $errfile . ' | ' . $errline;
140 140
 	}
141 141
 
142
-	function php_shudown_handler(){
142
+	function php_shudown_handler() {
143 143
 		return true;
144 144
 	}
145 145
 
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	/**
148 148
 	*  @test
149 149
 	*/
150
-	function attributes_to_string(array $attributes){
150
+	function attributes_to_string(array $attributes) {
151 151
 		$str = ' ';
152 152
 		//we check that the array passed as an argument is not empty.
153
-		if(! empty($attributes)){
154
-			foreach($attributes as $key => $value){
153
+		if (!empty($attributes)) {
154
+			foreach ($attributes as $key => $value) {
155 155
 				$key = trim(htmlspecialchars($key));
156 156
 				$value = trim(htmlspecialchars($value));
157 157
 				/*
@@ -161,35 +161,35 @@  discard block
 block discarded – undo
161 161
 				* 	$attr = array('placeholder' => 'I am a "puple"')
162 162
 				* 	$str = attributes_to_string($attr); => placeholder = "I am a \"puple\""
163 163
 				 */
164
-				if($value && strpos('"', $value) !== false){
164
+				if ($value && strpos('"', $value) !== false) {
165 165
 					$value = addslashes($value);
166 166
 				}
167
-				$str .= $key.' = "'.$value.'" ';
167
+				$str .= $key . ' = "' . $value . '" ';
168 168
 			}
169 169
 		}
170 170
 		//remove the space after using rtrim()
171 171
 		return rtrim($str);
172 172
 	}
173 173
 
174
-	function stringfy_vars($var){
174
+	function stringfy_vars($var) {
175 175
 		return print_r($var, true);
176 176
 	}
177 177
 
178 178
 	/**
179 179
 	*  @test
180 180
 	*/
181
-	function clean_input($str){
182
-		if(is_array($str)){
181
+	function clean_input($str) {
182
+		if (is_array($str)) {
183 183
 			$str = array_map('clean_input', $str);
184 184
 		}
185
-		else if(is_object($str)){
185
+		else if (is_object($str)) {
186 186
 			$obj = $str;
187 187
 			foreach ($str as $var => $value) {
188 188
 				$obj->$var = clean_input($value);
189 189
 			}
190 190
 			$str = $obj;
191 191
 		}
192
-		else{
192
+		else {
193 193
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
194 194
 		}
195 195
 		return $str;
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
 	/**
199 199
 	*  @test
200 200
 	*/
201
-	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
201
+	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') {
202 202
 		//get the string length
203 203
 		$len = strlen($str);
204 204
 		//if str is empty
205
-		if($len <= 0){
205
+		if ($len <= 0) {
206 206
 			return str_repeat($hiddenChar, 6);
207 207
 		}
208 208
 		//if the length is less than startCount and endCount
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 		//or startCount is negative or endCount is negative
211 211
 		//return the full string hidden
212 212
 		
213
-		if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
213
+		if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) {
214 214
 			return str_repeat($hiddenChar, $len);
215 215
 		}
216 216
 		//the start non hidden string
217 217
 		$startNonHiddenStr = substr($str, 0, $startCount);
218 218
 		//the end non hidden string
219 219
 		$endNonHiddenStr = null;
220
-		if($endCount > 0){
220
+		if ($endCount > 0) {
221 221
 			$endNonHiddenStr = substr($str, - $endCount);
222 222
 		}
223 223
 		//the hidden string
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 		return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr;
227 227
 	}
228 228
 	
229
-	function set_session_config(){
229
+	function set_session_config() {
230 230
 		return true;
231 231
 	}
232 232
 	
233 233
 	function & get_instance(){
234
-		if(! Controller::get_instance()){
234
+		if (!Controller::get_instance()) {
235 235
 			$c = new Controller();
236 236
 		}
237 237
 		return Controller::get_instance();
Please login to merge, or discard this patch.