Completed
Push — master ( 6da602...e92961 )
by Florian
04:20
created
lib/Payone/Log4php/LoggerOptionConverter.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 	 *					value if there is no property with that key.
60 60
 	 */
61 61
 	public static function getSystemProperty($key, $def) {
62
-		if(defined($key)) {
62
+		if (defined($key)) {
63 63
 			return (string)constant($key);
64
-		} else if(isset($_SERVER[$key])) {
64
+		} else if (isset($_SERVER[$key])) {
65 65
 			return (string)$_SERVER[$key];
66
-		} else if(isset($_ENV[$key])) {
66
+		} else if (isset($_ENV[$key])) {
67 67
 			return (string)$_ENV[$key];
68 68
 		} else {
69 69
 			return $def;
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 	 * @param boolean $default
83 83
 	 * @return boolean
84 84
 	 */
85
-	public static function toBoolean($value, $default=true) {
85
+	public static function toBoolean($value, $default = true) {
86 86
 		if (is_null($value)) {
87 87
 			return $default;
88 88
 		} elseif (is_string($value)) {
89 89
 			$trimmedVal = strtolower(trim($value));
90
-			if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) {
90
+			if ("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) {
91 91
 				return true;
92 92
 			} else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) {
93 93
 				return false;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public static function toInt($value, $default) {
128 128
 		$value = trim($value);
129
-		if(is_numeric($value)) {
129
+		if (is_numeric($value)) {
130 130
 			return (int)$value;
131 131
 		} else {
132 132
 			return $default;
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 		if (is_integer($value)) {
143 143
 			return $value;
144 144
 		}
145
-		if (is_numeric($value) && ($value == (integer) $value)) {
146
-			return (integer) $value;
145
+		if (is_numeric($value) && ($value == (integer)$value)) {
146
+			return (integer)$value;
147 147
 		}
148 148
 	
149 149
 		throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer.");
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 		if (is_integer($value) && $value > 0) {
158 158
 			return $value;
159 159
 		}
160
-		if (is_numeric($value) && ($value == (integer) $value) && $value > 0) {
161
-			return (integer) $value;
160
+		if (is_numeric($value) && ($value == (integer)$value) && $value > 0) {
161
+			return (integer)$value;
162 162
 		}
163 163
 	
164 164
 		throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 	 * @return Payone_Log4php_LoggerLevel a {@link LoggerLevel} or null
192 192
 	 */
193 193
 	public static function toLevel($value, $defaultValue) {
194
-		if($value === null) {
194
+		if ($value === null) {
195 195
 			return $defaultValue;
196 196
 		}
197 197
 		$hashIndex = strpos($value, '#');
198
-		if($hashIndex === false) {
199
-			if("NULL" == strtoupper($value)) {
198
+		if ($hashIndex === false) {
199
+			if ("NULL" == strtoupper($value)) {
200 200
 				return null;
201 201
 			} else {
202 202
 				// no class name specified : use standard Level class
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
 		$levelName = substr($value, 0, $hashIndex);
211 211
 
212 212
 		// This is degenerate case but you never know.
213
-		if("NULL" == strtoupper($levelName)) {
213
+		if ("NULL" == strtoupper($levelName)) {
214 214
 			return null;
215 215
 		}
216 216
 
217 217
 		$clazz = basename($clazz);
218 218
 
219
-		if(class_exists($clazz)) {
219
+		if (class_exists($clazz)) {
220 220
 			$result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
221
-			if(!$result instanceof Payone_Log4php_LoggerLevel) {
221
+			if (!$result instanceof Payone_Log4php_LoggerLevel) {
222 222
 				$result = $defaultValue;
223 223
 			}
224 224
 		} 
@@ -244,23 +244,23 @@  discard block
 block discarded – undo
244 244
 	 * @return float
245 245
 	 */
246 246
 	public static function toFileSize($value, $default) {
247
-		if($value === null) {
247
+		if ($value === null) {
248 248
 			return $default;
249 249
 		}
250 250
 
251 251
 		$s = strtoupper(trim($value));
252 252
 		$multiplier = (float)1;
253
-		if(($index = strpos($s, 'KB')) !== false) {
253
+		if (($index = strpos($s, 'KB')) !== false) {
254 254
 			$multiplier = 1024;
255 255
 			$s = substr($s, 0, $index);
256
-		} else if(($index = strpos($s, 'MB')) !== false) {
256
+		} else if (($index = strpos($s, 'MB')) !== false) {
257 257
 			$multiplier = 1024 * 1024;
258 258
 			$s = substr($s, 0, $index);
259
-		} else if(($index = strpos($s, 'GB')) !== false) {
259
+		} else if (($index = strpos($s, 'GB')) !== false) {
260 260
 			$multiplier = 1024 * 1024 * 1024;
261 261
 			$s = substr($s, 0, $index);
262 262
 		}
263
-		if(is_numeric($s)) {
263
+		if (is_numeric($s)) {
264 264
 			return (float)$s * $multiplier;
265 265
 		} 
266 266
 		return $default;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		}
291 291
 		
292 292
 		if (is_numeric($value)) {
293
-			return (integer) $value;
293
+			return (integer)$value;
294 294
 		}
295 295
 		
296 296
 		if (!is_string($value)) {
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
 			$size = $matches[1];
305 305
 			$unit = $matches[2];
306 306
 			
307
-			switch($unit) {
307
+			switch ($unit) {
308 308
 				case 'KB': $size *= pow(1024, 1); break;
309 309
 				case 'MB': $size *= pow(1024, 2); break;
310 310
 				case 'GB': $size *= pow(1024, 3); break;
311 311
 			}
312 312
 			
313
-			return (integer) $size;
313
+			return (integer)$size;
314 314
 		}
315 315
 		
316 316
 		throw new Payone_Log4php_LoggerException("Given value [$value] cannot be converted to a file size.");
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
 			return $value;
329 329
 		}
330 330
 		if (is_numeric($value)) {
331
-			return (string) $value;
331
+			return (string)$value;
332 332
 		}
333 333
 		if (is_object($value) && method_exists($value, '__toString')) {
334
-			return (string) $value;
334
+			return (string)$value;
335 335
 		}
336 336
 	
337 337
 		throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
 	public static function substVars($val, $props = null) {
407 407
 		$sbuf = '';
408 408
 		$i = 0;
409
-		while(true) {
409
+		while (true) {
410 410
 			$j = strpos($val, self::DELIM_START, $i);
411
-			if($j === false) {
411
+			if ($j === false) {
412 412
 				// no more variables
413
-				if($i == 0) { // this is a simple string
413
+				if ($i == 0) { // this is a simple string
414 414
 					return $val;
415 415
 				} else { // add the tail string which contails no variables and return the result.
416 416
 					$sbuf .= substr($val, $i);
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 				}
419 419
 			} else {
420 420
 			
421
-				$sbuf .= substr($val, $i, $j-$i);
421
+				$sbuf .= substr($val, $i, $j - $i);
422 422
 				$k = strpos($val, self::DELIM_STOP, $j);
423
-				if($k === false) {
423
+				if ($k === false) {
424 424
 					// LoggerOptionConverter::substVars() has no closing brace. Opening brace
425 425
 					return '';
426 426
 				} else {
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
 					// first try in System properties
430 430
 					$replacement = Payone_Log4php_LoggerOptionConverter::getSystemProperty($key, null);
431 431
 					// then try props parameter
432
-					if($replacement == null and $props !== null) {
432
+					if ($replacement == null and $props !== null) {
433 433
 						$replacement = @$props[$key];
434 434
 					}
435 435
 
436
-					if(!empty($replacement)) {
436
+					if (!empty($replacement)) {
437 437
 						// Do variable substitution on the replacement string
438 438
 						// such that we can solve "Hello ${x2}" as "Hello p1" 
439 439
 						// the where the properties are
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerPatternConverterThrowable.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	
33 33
 	public function activateOptions() {
34 34
 		if (isset($this->option) && is_numeric($op) && $op >= 0) {
35
-			$this->depth = (integer) $this->option;
35
+			$this->depth = (integer)$this->option;
36 36
 		}
37 37
 	}
38 38
 	
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 		
48 48
 		// Format exception to string
49 49
 		$strEx = get_class($ex) . ': "' . $ex->getMessage() . '"' . PHP_EOL;
50
-		$strEx .= 'at '. $ex->getFile() . ':' . $ex->getLine();
50
+		$strEx .= 'at ' . $ex->getFile() . ':' . $ex->getLine();
51 51
 		
52 52
 		// Add trace if required
53 53
 		if ($this->depth === null || $this->depth > 0) {
54 54
 			$trace = $ex->getTrace();
55
-			foreach($trace as $key => $item) {
55
+			foreach ($trace as $key => $item) {
56 56
 				if (isset($this->depth) && $key > $this->depth) {
57 57
 					break;
58 58
 				}
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerUtils.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		$name = trim($name, ' \\');
44 44
 		$fragments = explode('\\', $name);
45 45
 		
46
-		foreach($fragments as $key => $fragment) {
46
+		foreach ($fragments as $key => $fragment) {
47 47
 			if (trim($fragment) === '') {
48 48
 				unset($fragments[$key]);
49 49
 			}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			return $name;
95 95
 		}
96 96
 	
97
-		foreach($fragments as $key => &$fragment) {
97
+		foreach ($fragments as $key => &$fragment) {
98 98
 	
99 99
 			// Never shorten last fragment
100 100
 			if ($key == $count - 1) {
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerAppenderConsole.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,14 +80,14 @@
 block discarded – undo
80 80
 
81 81
 	public function activateOptions() {
82 82
 		$this->fp = fopen($this->target, 'w');
83
-		if(is_resource($this->fp) && $this->layout !== null) {
83
+		if (is_resource($this->fp) && $this->layout !== null) {
84 84
 			fwrite($this->fp, $this->layout->getHeader());
85 85
 		}
86 86
 		$this->closed = (bool)is_resource($this->fp) === false;
87 87
 	}
88 88
 	
89 89
 	public function close() {
90
-		if($this->closed != true) {
90
+		if ($this->closed != true) {
91 91
 			if (is_resource($this->fp) && $this->layout !== null) {
92 92
 				fwrite($this->fp, $this->layout->getFooter());
93 93
 				fclose($this->fp);
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerAppenderRollingFile.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	private function rollOver() {
116 116
 		// If maxBackups <= 0, then there is no file renaming to be done.
117
-		if($this->maxBackupIndex > 0) {
117
+		if ($this->maxBackupIndex > 0) {
118 118
 			$fileName = $this->getExpandedFileName();
119 119
 
120 120
 			// Delete the oldest file, to keep Windows happy.
121 121
 			$file = $fileName . '.' . $this->maxBackupIndex;
122
-			if(is_writable($file))
122
+			if (is_writable($file))
123 123
 				unlink($file);
124 124
 
125 125
 			// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
126
-			for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
126
+			for ($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
127 127
 				$file = $fileName . "." . $i;
128
-				if(is_readable($file)) {
128
+				if (is_readable($file)) {
129 129
 					$target = $fileName . '.' . ($i + 1);
130 130
 					rename($file, $target);
131 131
 				}
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 
197 197
 	public function append(Payone_Log4php_LoggerLoggingEvent $event) {
198
-		if($this->fp and $this->layout !== null) {
199
-			if(flock($this->fp, LOCK_EX)) {
198
+		if ($this->fp and $this->layout !== null) {
199
+			if (flock($this->fp, LOCK_EX)) {
200 200
 				fwrite($this->fp, $this->layout->format($event));
201 201
 
202 202
 				// Stats cache must be cleared, otherwise filesize() returns cached results
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerAppenderSyslog.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	}
230 230
 	
231 231
 	public function close() {
232
-		if($this->closed != true) {
232
+		if ($this->closed != true) {
233 233
 			closelog();
234 234
 			$this->closed = true;
235 235
 		}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	
256 256
 	/** Determines which syslog priority to use based on the given level. */
257 257
 	private function getSyslogPriority(Payone_Log4php_LoggerLevel $level) {
258
-		if($this->overridePriority) {
258
+		if ($this->overridePriority) {
259 259
 			return $this->intPriority;
260 260
 		}
261 261
 		return $level->getSyslogEquivalent();
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		$value = 0;
267 267
 		$options = explode('|', $this->option);
268 268
 	
269
-		foreach($options as $option) {
269
+		foreach ($options as $option) {
270 270
 			if (!empty($option)) {
271 271
 				$constant = "LOG_" . trim($option);
272 272
 				if (defined($constant)) {
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerAutoloader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@
 block discarded – undo
133 133
 	 * @param string $className The name of the class to load.
134 134
 	 */
135 135
 	public static function autoload($className) {
136
-		if(isset(self::$classes[$className])) {
136
+		if (isset(self::$classes[$className])) {
137 137
 			require_once dirname(__FILE__) . self::$classes[$className];
138 138
 		}
139 139
 	}
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerLayoutXml.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
  * @subpackage layouts
55 55
  */
56 56
 class Payone_Log4php_LoggerLayoutXml extends Payone_Log4php_LoggerLayout {
57
-	const LOG4J_NS_PREFIX ='log4j';
57
+	const LOG4J_NS_PREFIX = 'log4j';
58 58
 	const LOG4J_NS = 'http://jakarta.apache.org/log4j/';
59 59
 	
60 60
 	const LOG4PHP_NS_PREFIX = 'log4php';
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 	 * @return string
100 100
 	 */
101 101
 	public function getHeader() {
102
-		return "<{$this->namespacePrefix}:eventSet ".
103
-			"xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" ".
104
-			"version=\"0.3\" ".
105
-			"includesLocationInfo=\"".($this->getLocationInfo() ? "true" : "false")."\"".
102
+		return "<{$this->namespacePrefix}:eventSet " .
103
+			"xmlns:{$this->namespacePrefix}=\"{$this->namespace}\" " .
104
+			"version=\"0.3\" " .
105
+			"includesLocationInfo=\"" . ($this->getLocationInfo() ? "true" : "false") . "\"" .
106 106
 			">" . PHP_EOL;
107 107
 	}
108 108
 
@@ -120,38 +120,38 @@  discard block
 block discarded – undo
120 120
 		$thread = $event->getThreadName();
121 121
 		$level = $event->getLevel()->toString();
122 122
 
123
-		$buf  = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
123
+		$buf  = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">" . PHP_EOL;
124 124
 		$buf .= "<$ns:message>"; 
125 125
 		$buf .= $this->encodeCDATA($event->getRenderedMessage()); 
126
-		$buf .= "</$ns:message>".PHP_EOL;
126
+		$buf .= "</$ns:message>" . PHP_EOL;
127 127
 
128 128
 		$ndc = $event->getNDC();
129
-		if(!empty($ndc)) {
129
+		if (!empty($ndc)) {
130 130
 			$buf .= "<$ns:NDC><![CDATA[";
131 131
 			$buf .= $this->encodeCDATA($ndc);
132
-			$buf .= "]]></$ns:NDC>".PHP_EOL;
132
+			$buf .= "]]></$ns:NDC>" . PHP_EOL;
133 133
 		}
134 134
 		
135 135
 		$mdcMap = $event->getMDCMap();
136 136
 		if (!empty($mdcMap)) {
137
-			$buf .= "<$ns:properties>".PHP_EOL;
137
+			$buf .= "<$ns:properties>" . PHP_EOL;
138 138
 			foreach ($mdcMap as $name=>$value) {
139
-				$buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL;
139
+				$buf .= "<$ns:data name=\"$name\" value=\"$value\" />" . PHP_EOL;
140 140
 			}
141
-			$buf .= "</$ns:properties>".PHP_EOL;
141
+			$buf .= "</$ns:properties>" . PHP_EOL;
142 142
 		}
143 143
 
144 144
 		if ($this->getLocationInfo()) {
145 145
 			$locationInfo = $event->getLocationInformation();
146
-			$buf .= "<$ns:locationInfo ". 
147
-					"class=\"" . $locationInfo->getClassName() . "\" ".
148
-					"file=\"" .  htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ".
149
-					"line=\"" .  $locationInfo->getLineNumber() . "\" ".
146
+			$buf .= "<$ns:locationInfo " . 
147
+					"class=\"" . $locationInfo->getClassName() . "\" " .
148
+					"file=\"" . htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" " .
149
+					"line=\"" . $locationInfo->getLineNumber() . "\" " .
150 150
 					"method=\"" . $locationInfo->getMethodName() . "\" ";
151
-			$buf .= "/>".PHP_EOL;
151
+			$buf .= "/>" . PHP_EOL;
152 152
 		}
153 153
 
154
-		$buf .= "</$ns:event>".PHP_EOL;
154
+		$buf .= "</$ns:event>" . PHP_EOL;
155 155
 		
156 156
 		return $buf;
157 157
 	}
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerMDC.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@
 block discarded – undo
75 75
 	 * 	for given key.
76 76
 	 */
77 77
 	public static function get($key) {
78
-		if(!empty($key)) {
79
-			if(strpos($key, 'server.') === 0) {
78
+		if (!empty($key)) {
79
+			if (strpos($key, 'server.') === 0) {
80 80
 				$varName = substr($key, 7);
81 81
 				return isset($_SERVER[$varName]) ? $_SERVER[$varName] : '';
82
-			} else if(strpos($key, 'env.') === 0) {
82
+			} else if (strpos($key, 'env.') === 0) {
83 83
 				$varName = substr($key, 4);
84 84
 				$value = getenv($varName);
85 85
 				return ($value !== false) ? $value : '';
Please login to merge, or discard this patch.