Completed
Branch master (d77618)
by Florian
06:00
created
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.
lib/Payone/Log4php/LoggerConfigurationAdapterXML.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
 		}
51 51
 		
52 52
 		// Process <logger> nodes
53
-		foreach($xml->logger as $logger) {
53
+		foreach ($xml->logger as $logger) {
54 54
 			$this->parseLogger($logger);
55 55
 		} 
56 56
 		
57 57
 		// Process <appender> nodes
58
-		foreach($xml->appender as $appender) {
58
+		foreach ($xml->appender as $appender) {
59 59
 			$this->parseAppender($appender);
60 60
 		}
61 61
 		
62 62
 		// Process <renderer> nodes
63
-		foreach($xml->renderer as $rendererNode) {
63
+		foreach ($xml->renderer as $rendererNode) {
64 64
 			$this->parseRenderer($rendererNode);
65 65
 		}
66 66
 		return $this->config;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		if ($xml === false) {
84 84
 			
85 85
 			$errorStr = "";
86
-			foreach(libxml_get_errors() as $error) {
86
+			foreach (libxml_get_errors() as $error) {
87 87
 				$errorStr .= $error->message;
88 88
 			}
89 89
 			
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	private function parseConfiguration(SimpleXMLElement $xml) {
103 103
 		$attributes = $xml->attributes();
104 104
 		if (isset($attributes['threshold'])) {
105
-			$this->config['threshold'] = (string) $attributes['threshold'];
105
+			$this->config['threshold'] = (string)$attributes['threshold'];
106 106
 		}
107 107
 	}
108 108
 	
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 		}
123 123
 		
124 124
 		if (isset($node->layout)) {
125
-			$appender['layout']= $this->parseLayout($node->layout, $name);
125
+			$appender['layout'] = $this->parseLayout($node->layout, $name);
126 126
 		}
127 127
 		
128 128
 		if (count($node->param) > 0) {
129 129
 			$appender['params'] = $this->parseParameters($node);
130 130
 		}
131 131
 		
132
-		foreach($node->filter as $filterNode) {
132
+		foreach ($node->filter as $filterNode) {
133 133
 			$appender['filters'][] = $this->parseFilter($filterNode);
134 134
 		}
135 135
 		
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	private function parseParameters($paramsNode) {
153 153
 		$params = array();
154 154
 
155
-		foreach($paramsNode->param as $paramNode) {
155
+		foreach ($paramsNode->param as $paramNode) {
156 156
 			if (empty($paramNode['name'])) {
157 157
 				$this->warn("A <param> node is missing the required 'name' attribute. Skipping parameter.");
158 158
 				continue;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		}
177 177
 		
178 178
 		$logger['appenders'] = array();
179
-		foreach($node->appender_ref as $appender) {
179
+		foreach ($node->appender_ref as $appender) {
180 180
 			$logger['appenders'][] = $this->getAttributeValue($appender, 'ref');
181 181
 		}
182 182
 		
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	private function parseAppenderReferences(SimpleXMLElement $node, $name) {
218 218
 		$refs = array();
219
-		foreach($node->appender_ref as $ref) {
219
+		foreach ($node->appender_ref as $ref) {
220 220
 			$refs[] = $this->getAttributeValue($ref, 'ref');
221 221
 		}
222 222
 		
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	// ******************************************
249 249
 	
250 250
 	private function getAttributeValue(SimpleXMLElement $node, $name) {
251
-		return isset($node[$name]) ? (string) $node[$name] : null;
251
+		return isset($node[$name]) ? (string)$node[$name] : null;
252 252
 	}
253 253
 	
254 254
 	private function warn($message) {
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerAppender.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @param LoggerFilter $filter add a new LoggerFilter
102 102
 	 */
103 103
 	public function addFilter($filter) {
104
-		if($this->filter === null) {
104
+		if ($this->filter === null) {
105 105
 			$this->filter = $filter;
106 106
 		} else {
107 107
 			$this->filter->addNext($filter);
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
 	 * @param Payone_Log4php_LoggerLoggingEvent $event
141 141
 	 */
142 142
 	public function doAppend(Payone_Log4php_LoggerLoggingEvent $event) {
143
-		if($this->closed) {
143
+		if ($this->closed) {
144 144
 			return;
145 145
 		}
146 146
 		
147
-		if(!$this->isAsSevereAsThreshold($event->getLevel())) {
147
+		if (!$this->isAsSevereAsThreshold($event->getLevel())) {
148 148
 			return;
149 149
 		}
150 150
 
151 151
 		$f = $this->getFirstFilter();
152
-		while($f !== null) {
152
+		while ($f !== null) {
153 153
 			switch ($f->decide($event)) {
154 154
 				case Payone_Log4php_LoggerFilter::DENY: return;
155 155
 				case Payone_Log4php_LoggerFilter::ACCEPT: return $this->append($event);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @param Payone_Log4php_LoggerLayout $layout
165 165
 	 */
166 166
 	public function setLayout($layout) {
167
-		if($this->requiresLayout()) {
167
+		if ($this->requiresLayout()) {
168 168
 			$this->layout = $layout;
169 169
 		}
170 170
 	} 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 *   threshold, or if the threshold is not set. Otherwise returns false.
244 244
 	 */
245 245
 	public function isAsSevereAsThreshold($level) {
246
-		if($this->threshold === null) {
246
+		if ($this->threshold === null) {
247 247
 			return true;
248 248
 		}
249 249
 		return $level->isGreaterOrEqual($this->getThreshold());
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerAppenderFile.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
 			return;
67 67
 		}
68 68
 		
69
-		if(!is_file($fileName)) {
69
+		if (!is_file($fileName)) {
70 70
 			$dir = dirname($fileName);
71
-			if(!is_dir($dir)) {
71
+			if (!is_dir($dir)) {
72 72
 				mkdir($dir, 0777, true);
73 73
 			}
74 74
 		}
75 75
 
76
-		$this->fp = fopen($fileName, ($this->getAppend()? 'a':'w'));
77
-		if($this->fp) {
78
-			if(flock($this->fp, LOCK_EX)) {
79
-				if($this->getAppend()) {
76
+		$this->fp = fopen($fileName, ($this->getAppend() ? 'a' : 'w'));
77
+		if ($this->fp) {
78
+			if (flock($this->fp, LOCK_EX)) {
79
+				if ($this->getAppend()) {
80 80
 					fseek($this->fp, 0, SEEK_END);
81 81
 				}
82 82
 				fwrite($this->fp, $this->layout->getHeader());
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 	}
93 93
 	
94 94
 	public function close() {
95
-		if($this->closed != true) {
96
-			if($this->fp and $this->layout !== null) {
97
-				if(flock($this->fp, LOCK_EX)) {
95
+		if ($this->closed != true) {
96
+			if ($this->fp and $this->layout !== null) {
97
+				if (flock($this->fp, LOCK_EX)) {
98 98
 					fwrite($this->fp, $this->layout->getFooter());
99 99
 					flock($this->fp, LOCK_UN);
100 100
 				}
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	public function append(Payone_Log4php_LoggerLoggingEvent $event) {
108
-		if($this->fp and $this->layout !== null) {
109
-			if(flock($this->fp, LOCK_EX)) {
108
+		if ($this->fp and $this->layout !== null) {
109
+			if (flock($this->fp, LOCK_EX)) {
110 110
 				fwrite($this->fp, $this->layout->format($event));
111 111
 				flock($this->fp, LOCK_UN);
112 112
 			} else {
Please login to merge, or discard this patch.
lib/Payone/Log4php/Logger.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 *   in the logging event.
170 170
 	 */
171 171
 	public function log(Payone_Log4php_LoggerLevel $level, $message, $throwable = null) {
172
-		if($this->isEnabledFor($level)) {
172
+		if ($this->isEnabledFor($level)) {
173 173
 			$this->forcedLog($this->fqcn, $throwable, $level, $message);
174 174
 		}
175 175
 	}
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @param string $msg message to log
183 183
 	 */
184 184
 	public function assertLog($assertion = true, $msg = '') {
185
-		if($assertion == false) {
185
+		if ($assertion == false) {
186 186
 			$this->error($msg);
187 187
 		}
188 188
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	
286 286
 	/** Removes all appenders from the Logger. */
287 287
 	public function removeAllAppenders() {
288
-		foreach($this->appenders as $name => $appender) {
288
+		foreach ($this->appenders as $name => $appender) {
289 289
 			$this->removeAppender($name);
290 290
 		}
291 291
 	} 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 * @param mixed $appender an appender name or a {@link Payone_Log4php_LoggerAppender} instance.
296 296
 	 */
297 297
 	public function removeAppender($appender) {
298
-		if($appender instanceof Payone_Log4php_LoggerAppender) {
298
+		if ($appender instanceof Payone_Log4php_LoggerAppender) {
299 299
 			$appender->close();
300 300
 			unset($this->appenders[$appender->getName()]);
301 301
 		} else if (is_string($appender) and isset($this->appenders[$appender])) {
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
 	 */
311 311
 	public function callAppenders($event) {
312 312
 		// Forward the event to each linked appender
313
-		foreach($this->appenders as $appender) {
313
+		foreach ($this->appenders as $appender) {
314 314
 			$appender->doAppend($event);
315 315
 		}
316 316
 		
317 317
 		// Forward the event upstream if additivity is turned on
318
-		if(isset($this->parent) && $this->getAdditivity()) {
318
+		if (isset($this->parent) && $this->getAdditivity()) {
319 319
 			$this->parent->callAppenders($event);
320 320
 		}
321 321
 	}
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 * @return Payone_Log4php_LoggerLevel or null
359 359
 	 */
360 360
 	public function getEffectiveLevel() {
361
-		for($logger = $this; $logger !== null; $logger = $logger->getParent()) {
362
-			if($logger->getLevel() !== null) {
361
+		for ($logger = $this; $logger !== null; $logger = $logger->getParent()) {
362
+			if ($logger->getLevel() !== null) {
363 363
 				return $logger->getLevel();
364 364
 			}
365 365
 		}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	 * @return Payone_Log4php_LoggerHierarchy
422 422
 	 */
423 423
 	public static function getHierarchy() {
424
-		if(!isset(self::$hierarchy)) {
424
+		if (!isset(self::$hierarchy)) {
425 425
 			self::$hierarchy = new Payone_Log4php_LoggerHierarchy(new Payone_Log4php_LoggerRoot());
426 426
 		}
427 427
 		return self::$hierarchy;
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	 * @return Logger
435 435
 	 */
436 436
 	public static function getLogger($name) {
437
-		if(!self::isInitialized()) {
437
+		if (!self::isInitialized()) {
438 438
 			self::configure();
439 439
 		}
440 440
 		return self::getHierarchy()->getLogger($name);
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * @return Payone_Log4php_LoggerRoot
446 446
 	 */
447 447
 	public static function getRootLogger() {
448
-		if(!self::isInitialized()) {
448
+		if (!self::isInitialized()) {
449 449
 			self::configure();
450 450
 		}
451 451
 		return self::getHierarchy()->getRootLogger();
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerAppenderMongoDB.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	public function activateOptions() {
125 125
 		try {
126 126
 			$this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array("timeout" => $this->timeout));
127
-			$db	= $this->connection->selectDB($this->databaseName);
127
+			$db = $this->connection->selectDB($this->databaseName);
128 128
 			if ($this->userName !== null && $this->password !== null) {
129 129
 				$authResult = $db->authenticate($this->userName, $this->password);
130 130
 				if ($authResult['ok'] == floatval(0)) {
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
 	 * @return array The array representation of the logging event.
161 161
 	 */
162 162
 	protected function format(Payone_Log4php_LoggerLoggingEvent $event) {
163
-		$timestampSec  = (int) $event->getTimestamp();
164
-		$timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);
163
+		$timestampSec  = (int)$event->getTimestamp();
164
+		$timestampUsec = (int)(($event->getTimestamp() - $timestampSec) * 1000000);
165 165
 
166 166
 		$document = array(
167 167
 			'timestamp'  => new MongoDate($timestampSec, $timestampUsec),
168 168
 			'level'      => $event->getLevel()->toString(),
169
-			'thread'     => (int) $event->getThreadName(),
169
+			'thread'     => (int)$event->getThreadName(),
170 170
 			'message'    => $event->getMessage(),
171 171
 			'loggerName' => $event->getLoggerName() 
172 172
 		);	
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		if ($locationInfo != null) {
176 176
 			$document['fileName']   = $locationInfo->getFileName();
177 177
 			$document['method']     = $locationInfo->getMethodName();
178
-			$document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int) $locationInfo->getLineNumber();
178
+			$document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int)$locationInfo->getLineNumber();
179 179
 			$document['className']  = $locationInfo->getClassName();
180 180
 		}	
181 181
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * Closes the connection to the logging database
214 214
 	 */
215 215
 	public function close() {
216
-		if($this->closed != true) {
216
+		if ($this->closed != true) {
217 217
 			$this->collection = null;
218 218
 			if ($this->connection !== null) {
219 219
 				$this->connection->close();
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerRendererMap.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function addRenderer($renderedClassName, $renderingClassName) {
66 66
 		$renderer = Payone_Log4php_LoggerReflectionUtils::createObject($renderingClassName);
67
-		if($renderer == null) {
67
+		if ($renderer == null) {
68 68
 			return;
69 69
 		} else {
70 70
 			$this->put($renderedClassName, $renderer);
@@ -85,12 +85,12 @@  discard block
 block discarded – undo
85 85
 	 * @return string 
86 86
 	 */
87 87
 	public function findAndRender($o) {
88
-		if($o == null) {
88
+		if ($o == null) {
89 89
 			return null;
90 90
 		} else {
91
-			if(is_object($o)) {
91
+			if (is_object($o)) {
92 92
 				$renderer = $this->getByObject($o);
93
-				if($renderer !== null) {
93
+				if ($renderer !== null) {
94 94
 					return $renderer->render($o);
95 95
 				} else {
96 96
 					return null;
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function getByClassName($class) {
127 127
 		$r = null;
128
-		for($c = $class; !empty($c); $c = get_parent_class($c)) {
128
+		for ($c = $class; !empty($c); $c = get_parent_class($c)) {
129 129
 			$c = strtolower($c);
130
-			if(isset($this->map[$c])) {
130
+			if (isset($this->map[$c])) {
131 131
 				return $this->map[$c];
132 132
 			}
133 133
 		}
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerRoot.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	public function __construct($level = null) {
35 35
 		parent::__construct('root');
36 36
 
37
-		if($level == null) {
37
+		if ($level == null) {
38 38
 			$level = Payone_Log4php_LoggerLevel::getLevelAll();
39 39
 		}
40 40
 		$this->setLevel($level);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param Payone_Log4php_LoggerLevel $level
53 53
 	 */
54 54
 	public function setLevel($level) {
55
-		if($level != null) {
55
+		if ($level != null) {
56 56
 			parent::setLevel($level);
57 57
 		}	 
58 58
 	}
Please login to merge, or discard this patch.