Completed
Branch master (d77618)
by Florian
06:00
created
lib/Payone/Log4php/Logger.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 	/**
86 86
 	 * Returns the parent Logger. Can be null if this is the root logger.
87
-	 * @return Logger
87
+	 * @return Payone_Log4php_Logger
88 88
 	 */
89 89
 	public function getParent() {
90 90
 		return $this->parent;
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 
396 396
 	/**
397 397
 	 * Sets the parent logger.
398
-	 * @param Logger $logger
398
+	 * @param Payone_Log4php_Logger $logger
399 399
 	 */
400 400
 	public function setParent(Payone_Log4php_Logger $logger) {
401 401
 		$this->parent = $logger;
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	
454 454
 	/**
455 455
 	 * Clears all Logger definitions from the logger hierarchy.
456
-	 * @return boolean
456
+	 * @return boolean|null
457 457
 	 */
458 458
 	public static function clear() {
459 459
 		return self::getHierarchy()->clear();
Please login to merge, or discard this patch.
Indentation   +503 added lines, -503 removed lines patch added patch discarded remove patch
@@ -41,531 +41,531 @@
 block discarded – undo
41 41
  */
42 42
 class Payone_Log4php_Logger {
43 43
 	
44
-	/**
45
-	 * Logger additivity. If set to true then child loggers will inherit
46
-	 * the appenders of their ancestors by default.
47
-	 * @var boolean
48
-	 */
49
-	private $additive = true;
50
-	
51
-	/** 
52
-	 * The Logger's fully qualified class name.
53
-	 * TODO: Determine if this is useful. 
54
-	 */
55
-	private $fqcn = 'Logger';
44
+    /**
45
+     * Logger additivity. If set to true then child loggers will inherit
46
+     * the appenders of their ancestors by default.
47
+     * @var boolean
48
+     */
49
+    private $additive = true;
50
+	
51
+    /** 
52
+     * The Logger's fully qualified class name.
53
+     * TODO: Determine if this is useful. 
54
+     */
55
+    private $fqcn = 'Logger';
56 56
 
57
-	/** The assigned Logger level. */
58
-	private $level;
57
+    /** The assigned Logger level. */
58
+    private $level;
59 59
 	
60
-	/** The name of this Logger instance. */
61
-	private $name;
60
+    /** The name of this Logger instance. */
61
+    private $name;
62 62
 	
63
-	/** The parent logger. Set to null if this is the root logger. */
64
-	private $parent;
63
+    /** The parent logger. Set to null if this is the root logger. */
64
+    private $parent;
65 65
 	
66
-	/** A collection of appenders linked to this logger. */
67
-	private $appenders = array();
66
+    /** A collection of appenders linked to this logger. */
67
+    private $appenders = array();
68 68
 
69
-	/**
70
-	 * Constructor.
71
-	 * @param string $name Name of the logger.	  
72
-	 */
73
-	public function __construct($name) {
74
-		$this->name = $name;
75
-	}
76
-	
77
-	/**
78
-	 * Returns the logger name.
79
-	 * @return string
80
-	 */
81
-	public function getName() {
82
-		return $this->name;
83
-	} 
69
+    /**
70
+     * Constructor.
71
+     * @param string $name Name of the logger.	  
72
+     */
73
+    public function __construct($name) {
74
+        $this->name = $name;
75
+    }
76
+	
77
+    /**
78
+     * Returns the logger name.
79
+     * @return string
80
+     */
81
+    public function getName() {
82
+        return $this->name;
83
+    } 
84 84
 
85
-	/**
86
-	 * Returns the parent Logger. Can be null if this is the root logger.
87
-	 * @return Logger
88
-	 */
89
-	public function getParent() {
90
-		return $this->parent;
91
-	}
92
-	
93
-	// ******************************************
94
-	// *** Logging methods                    ***
95
-	// ******************************************
96
-	
97
-	/**
98
-	 * Log a message object with the TRACE level.
99
-	 *
100
-	 * @param mixed $message message
101
- 	 * @param Exception $throwable Optional throwable information to include 
102
-	 *   in the logging event.
103
-	 */
104
-	public function trace($message, $throwable = null) {
105
-		$this->log(Payone_Log4php_LoggerLevel::getLevelTrace(), $message, $throwable);
106
-	} 		
107
-	
108
-	/**
109
-	 * Log a message object with the DEBUG level.
110
-	 *
111
-	 * @param mixed $message message
112
- 	 * @param Exception $throwable Optional throwable information to include 
113
-	 *   in the logging event.
114
-	 */
115
-	public function debug($message, $throwable = null) {
116
-		$this->log(Payone_Log4php_LoggerLevel::getLevelDebug(), $message, $throwable);
117
-	} 
85
+    /**
86
+     * Returns the parent Logger. Can be null if this is the root logger.
87
+     * @return Logger
88
+     */
89
+    public function getParent() {
90
+        return $this->parent;
91
+    }
92
+	
93
+    // ******************************************
94
+    // *** Logging methods                    ***
95
+    // ******************************************
96
+	
97
+    /**
98
+     * Log a message object with the TRACE level.
99
+     *
100
+     * @param mixed $message message
101
+     * @param Exception $throwable Optional throwable information to include 
102
+     *   in the logging event.
103
+     */
104
+    public function trace($message, $throwable = null) {
105
+        $this->log(Payone_Log4php_LoggerLevel::getLevelTrace(), $message, $throwable);
106
+    } 		
107
+	
108
+    /**
109
+     * Log a message object with the DEBUG level.
110
+     *
111
+     * @param mixed $message message
112
+     * @param Exception $throwable Optional throwable information to include 
113
+     *   in the logging event.
114
+     */
115
+    public function debug($message, $throwable = null) {
116
+        $this->log(Payone_Log4php_LoggerLevel::getLevelDebug(), $message, $throwable);
117
+    } 
118 118
 
119
-	/**
120
-	 * Log a message object with the INFO Level.
121
-	 *
122
-	 * @param mixed $message message
123
- 	 * @param Exception $throwable Optional throwable information to include 
124
-	 *   in the logging event.
125
-	 */
126
-	public function info($message, $throwable = null) {
127
-		$this->log(Payone_Log4php_LoggerLevel::getLevelInfo(), $message, $throwable);
128
-	}
119
+    /**
120
+     * Log a message object with the INFO Level.
121
+     *
122
+     * @param mixed $message message
123
+     * @param Exception $throwable Optional throwable information to include 
124
+     *   in the logging event.
125
+     */
126
+    public function info($message, $throwable = null) {
127
+        $this->log(Payone_Log4php_LoggerLevel::getLevelInfo(), $message, $throwable);
128
+    }
129 129
 
130
-	/**
131
-	 * Log a message with the WARN level.
132
-	 *
133
-	 * @param mixed $message message
134
-  	 * @param Exception $throwable Optional throwable information to include 
135
-	 *   in the logging event.
136
-	 */
137
-	public function warn($message, $throwable = null) {
138
-		$this->log(Payone_Log4php_LoggerLevel::getLevelWarn(), $message, $throwable);
139
-	}
140
-	
141
-	/**
142
-	 * Log a message object with the ERROR level.
143
-	 *
144
-	 * @param mixed $message message
145
-	 * @param Exception $throwable Optional throwable information to include 
146
-	 *   in the logging event.
147
-	 */
148
-	public function error($message, $throwable = null) {
149
-		$this->log(Payone_Log4php_LoggerLevel::getLevelError(), $message, $throwable);
150
-	}
151
-	
152
-	/**
153
-	 * Log a message object with the FATAL level.
154
-	 *
155
-	 * @param mixed $message message
156
-	 * @param Exception $throwable Optional throwable information to include 
157
-	 *   in the logging event.
158
-	 */
159
-	public function fatal($message, $throwable = null) {
160
-		$this->log(Payone_Log4php_LoggerLevel::getLevelFatal(), $message, $throwable);
161
-	}
130
+    /**
131
+     * Log a message with the WARN level.
132
+     *
133
+     * @param mixed $message message
134
+     * @param Exception $throwable Optional throwable information to include 
135
+     *   in the logging event.
136
+     */
137
+    public function warn($message, $throwable = null) {
138
+        $this->log(Payone_Log4php_LoggerLevel::getLevelWarn(), $message, $throwable);
139
+    }
140
+	
141
+    /**
142
+     * Log a message object with the ERROR level.
143
+     *
144
+     * @param mixed $message message
145
+     * @param Exception $throwable Optional throwable information to include 
146
+     *   in the logging event.
147
+     */
148
+    public function error($message, $throwable = null) {
149
+        $this->log(Payone_Log4php_LoggerLevel::getLevelError(), $message, $throwable);
150
+    }
151
+	
152
+    /**
153
+     * Log a message object with the FATAL level.
154
+     *
155
+     * @param mixed $message message
156
+     * @param Exception $throwable Optional throwable information to include 
157
+     *   in the logging event.
158
+     */
159
+    public function fatal($message, $throwable = null) {
160
+        $this->log(Payone_Log4php_LoggerLevel::getLevelFatal(), $message, $throwable);
161
+    }
162 162
 
163
-	/**
164
-	 * Log a message using the provided logging level.
165
-	 *
166
-	 * @param Payone_Log4php_LoggerLevel $level The logging level.
167
-	 * @param mixed $message Message to log.
168
- 	 * @param Exception $throwable Optional throwable information to include 
169
-	 *   in the logging event.
170
-	 */
171
-	public function log(Payone_Log4php_LoggerLevel $level, $message, $throwable = null) {
172
-		if($this->isEnabledFor($level)) {
173
-			$this->forcedLog($this->fqcn, $throwable, $level, $message);
174
-		}
175
-	}
176
-	
177
-	/**
178
-	 * If assertion parameter evaluates as false, then logs the message 
179
-	 * using the ERROR level.
180
-	 *
181
-	 * @param bool $assertion
182
-	 * @param string $msg message to log
183
-	 */
184
-	public function assertLog($assertion = true, $msg = '') {
185
-		if($assertion == false) {
186
-			$this->error($msg);
187
-		}
188
-	}
189
-	
190
-	/**
191
-	 * This method creates a new logging event and logs the event without 
192
-	 * further checks.
193
-	 *
194
-	 * It should not be called directly. Use {@link trace()}, {@link debug()},
195
-	 * {@link info()}, {@link warn()}, {@link error()} and {@link fatal()} 
196
-	 * wrappers.
197
-	 *
198
-	 * @param string $fqcn Fully qualified class name of the Logger
199
-	 * @param Exception $throwable Optional throwable information to include 
200
-	 *   in the logging event.
201
-	 * @param Payone_Log4php_LoggerLevel $level log level
202
-	 * @param mixed $message message to log
203
-	 */
204
-	public function forcedLog($fqcn, $throwable, Payone_Log4php_LoggerLevel $level, $message) {
205
-		if (!($throwable instanceof Exception)) {
206
-			$throwable = null;
207
-		}
208
-		$this->callAppenders(new Payone_Log4php_LoggerLoggingEvent($fqcn, $this, $level, $message, null, $throwable));
209
-	} 
210
-	
211
-	// ******************************************
212
-	// *** Checker methods                    ***
213
-	// ******************************************
214
-	
215
-	/**
216
-	 * Check whether this Logger is enabled for a given Level passed as parameter.
217
-	 *
218
-	 * @param LoggerLevel level
219
-	 * @return boolean
220
-	 */
221
-	public function isEnabledFor(Payone_Log4php_LoggerLevel $level) {
222
-		return $level->isGreaterOrEqual($this->getEffectiveLevel());
223
-	}
224
-	
225
-	/**
226
-	 * Check whether this Logger is enabled for the TRACE Level.
227
-	 * @return boolean
228
-	 */
229
-	public function isTraceEnabled() {
230
-		return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelTrace());
231
-	}
232
-	
233
-	/**
234
-	 * Check whether this Logger is enabled for the DEBUG Level.
235
-	 * @return boolean
236
-	 */
237
-	public function isDebugEnabled() {
238
-		return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelDebug());
239
-	}
163
+    /**
164
+     * Log a message using the provided logging level.
165
+     *
166
+     * @param Payone_Log4php_LoggerLevel $level The logging level.
167
+     * @param mixed $message Message to log.
168
+     * @param Exception $throwable Optional throwable information to include 
169
+     *   in the logging event.
170
+     */
171
+    public function log(Payone_Log4php_LoggerLevel $level, $message, $throwable = null) {
172
+        if($this->isEnabledFor($level)) {
173
+            $this->forcedLog($this->fqcn, $throwable, $level, $message);
174
+        }
175
+    }
176
+	
177
+    /**
178
+     * If assertion parameter evaluates as false, then logs the message 
179
+     * using the ERROR level.
180
+     *
181
+     * @param bool $assertion
182
+     * @param string $msg message to log
183
+     */
184
+    public function assertLog($assertion = true, $msg = '') {
185
+        if($assertion == false) {
186
+            $this->error($msg);
187
+        }
188
+    }
189
+	
190
+    /**
191
+     * This method creates a new logging event and logs the event without 
192
+     * further checks.
193
+     *
194
+     * It should not be called directly. Use {@link trace()}, {@link debug()},
195
+     * {@link info()}, {@link warn()}, {@link error()} and {@link fatal()} 
196
+     * wrappers.
197
+     *
198
+     * @param string $fqcn Fully qualified class name of the Logger
199
+     * @param Exception $throwable Optional throwable information to include 
200
+     *   in the logging event.
201
+     * @param Payone_Log4php_LoggerLevel $level log level
202
+     * @param mixed $message message to log
203
+     */
204
+    public function forcedLog($fqcn, $throwable, Payone_Log4php_LoggerLevel $level, $message) {
205
+        if (!($throwable instanceof Exception)) {
206
+            $throwable = null;
207
+        }
208
+        $this->callAppenders(new Payone_Log4php_LoggerLoggingEvent($fqcn, $this, $level, $message, null, $throwable));
209
+    } 
210
+	
211
+    // ******************************************
212
+    // *** Checker methods                    ***
213
+    // ******************************************
214
+	
215
+    /**
216
+     * Check whether this Logger is enabled for a given Level passed as parameter.
217
+     *
218
+     * @param LoggerLevel level
219
+     * @return boolean
220
+     */
221
+    public function isEnabledFor(Payone_Log4php_LoggerLevel $level) {
222
+        return $level->isGreaterOrEqual($this->getEffectiveLevel());
223
+    }
224
+	
225
+    /**
226
+     * Check whether this Logger is enabled for the TRACE Level.
227
+     * @return boolean
228
+     */
229
+    public function isTraceEnabled() {
230
+        return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelTrace());
231
+    }
232
+	
233
+    /**
234
+     * Check whether this Logger is enabled for the DEBUG Level.
235
+     * @return boolean
236
+     */
237
+    public function isDebugEnabled() {
238
+        return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelDebug());
239
+    }
240 240
 
241
-	/**
242
-	 * Check whether this Logger is enabled for the INFO Level.
243
-	 * @return boolean
244
-	 */
245
-	public function isInfoEnabled() {
246
-		return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelInfo());
247
-	}
248
-	
249
-	/**
250
-	 * Check whether this Logger is enabled for the WARN Level.
251
-	 * @return boolean
252
-	 */
253
-	public function isWarnEnabled() {
254
-		return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelWarn());
255
-	}
256
-	
257
-	/**
258
-	 * Check whether this Logger is enabled for the ERROR Level.
259
-	 * @return boolean
260
-	 */
261
-	public function isErrorEnabled() {
262
-		return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelError());
263
-	}
264
-	
265
-	/**
266
-	 * Check whether this Logger is enabled for the FATAL Level.
267
-	 * @return boolean
268
-	 */
269
-	public function isFatalEnabled() {
270
-		return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelFatal());
271
-	}
272
-	
273
-	// ******************************************
274
-	// *** Configuration methods              ***
275
-	// ******************************************
276
-	
277
-	/**
278
-	 * Adds a new appender to the Logger.
279
-	 * @param Payone_Log4php_LoggerAppender $appender The appender to add.
280
-	 */
281
-	public function addAppender($appender) {
282
-		$appenderName = $appender->getName();
283
-		$this->appenders[$appenderName] = $appender;
284
-	}
285
-	
286
-	/** Removes all appenders from the Logger. */
287
-	public function removeAllAppenders() {
288
-		foreach($this->appenders as $name => $appender) {
289
-			$this->removeAppender($name);
290
-		}
291
-	} 
241
+    /**
242
+     * Check whether this Logger is enabled for the INFO Level.
243
+     * @return boolean
244
+     */
245
+    public function isInfoEnabled() {
246
+        return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelInfo());
247
+    }
248
+	
249
+    /**
250
+     * Check whether this Logger is enabled for the WARN Level.
251
+     * @return boolean
252
+     */
253
+    public function isWarnEnabled() {
254
+        return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelWarn());
255
+    }
256
+	
257
+    /**
258
+     * Check whether this Logger is enabled for the ERROR Level.
259
+     * @return boolean
260
+     */
261
+    public function isErrorEnabled() {
262
+        return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelError());
263
+    }
264
+	
265
+    /**
266
+     * Check whether this Logger is enabled for the FATAL Level.
267
+     * @return boolean
268
+     */
269
+    public function isFatalEnabled() {
270
+        return $this->isEnabledFor(Payone_Log4php_LoggerLevel::getLevelFatal());
271
+    }
272
+	
273
+    // ******************************************
274
+    // *** Configuration methods              ***
275
+    // ******************************************
276
+	
277
+    /**
278
+     * Adds a new appender to the Logger.
279
+     * @param Payone_Log4php_LoggerAppender $appender The appender to add.
280
+     */
281
+    public function addAppender($appender) {
282
+        $appenderName = $appender->getName();
283
+        $this->appenders[$appenderName] = $appender;
284
+    }
285
+	
286
+    /** Removes all appenders from the Logger. */
287
+    public function removeAllAppenders() {
288
+        foreach($this->appenders as $name => $appender) {
289
+            $this->removeAppender($name);
290
+        }
291
+    } 
292 292
 			
293
-	/**
294
-	 * Remove the appender passed as parameter form the Logger.
295
-	 * @param mixed $appender an appender name or a {@link Payone_Log4php_LoggerAppender} instance.
296
-	 */
297
-	public function removeAppender($appender) {
298
-		if($appender instanceof Payone_Log4php_LoggerAppender) {
299
-			$appender->close();
300
-			unset($this->appenders[$appender->getName()]);
301
-		} else if (is_string($appender) and isset($this->appenders[$appender])) {
302
-			$this->appenders[$appender]->close();
303
-			unset($this->appenders[$appender]);
304
-		}
305
-	}
306
-	
307
-	/**
308
-	 * Forwards the given logging event to all linked appenders.
309
-	 * @param Payone_Log4php_LoggerLoggingEvent $event
310
-	 */
311
-	public function callAppenders($event) {
312
-		// Forward the event to each linked appender
313
-		foreach($this->appenders as $appender) {
314
-			$appender->doAppend($event);
315
-		}
293
+    /**
294
+     * Remove the appender passed as parameter form the Logger.
295
+     * @param mixed $appender an appender name or a {@link Payone_Log4php_LoggerAppender} instance.
296
+     */
297
+    public function removeAppender($appender) {
298
+        if($appender instanceof Payone_Log4php_LoggerAppender) {
299
+            $appender->close();
300
+            unset($this->appenders[$appender->getName()]);
301
+        } else if (is_string($appender) and isset($this->appenders[$appender])) {
302
+            $this->appenders[$appender]->close();
303
+            unset($this->appenders[$appender]);
304
+        }
305
+    }
306
+	
307
+    /**
308
+     * Forwards the given logging event to all linked appenders.
309
+     * @param Payone_Log4php_LoggerLoggingEvent $event
310
+     */
311
+    public function callAppenders($event) {
312
+        // Forward the event to each linked appender
313
+        foreach($this->appenders as $appender) {
314
+            $appender->doAppend($event);
315
+        }
316 316
 		
317
-		// Forward the event upstream if additivity is turned on
318
-		if(isset($this->parent) && $this->getAdditivity()) {
319
-			$this->parent->callAppenders($event);
320
-		}
321
-	}
322
-	
323
-	/**
324
-	 * Returns the appenders linked to this logger as an array.
325
-	 * @return array collection of appender names
326
-	 */
327
-	public function getAllAppenders() {
328
-		return $this->appenders;
329
-	}
330
-	
331
-	/**
332
-	 * Returns a linked appender by name.
333
-	 * @return Payone_Log4php_LoggerAppender
334
-	 */
335
-	public function getAppender($name) {
336
-		return $this->appenders[$name];
337
-	}
317
+        // Forward the event upstream if additivity is turned on
318
+        if(isset($this->parent) && $this->getAdditivity()) {
319
+            $this->parent->callAppenders($event);
320
+        }
321
+    }
322
+	
323
+    /**
324
+     * Returns the appenders linked to this logger as an array.
325
+     * @return array collection of appender names
326
+     */
327
+    public function getAllAppenders() {
328
+        return $this->appenders;
329
+    }
330
+	
331
+    /**
332
+     * Returns a linked appender by name.
333
+     * @return Payone_Log4php_LoggerAppender
334
+     */
335
+    public function getAppender($name) {
336
+        return $this->appenders[$name];
337
+    }
338 338
 
339
-	/**
340
-	 * Sets the additivity flag.
341
-	 * @param boolean $additive
342
-	 */
343
-	public function setAdditivity($additive) {
344
-		$this->additive = (bool)$additive;
345
-	}
346
-	
347
-	/**
348
-	 * Returns the additivity flag.
349
-	 * @return boolean
350
-	 */
351
-	public function getAdditivity() {
352
-		return $this->additive;
353
-	}
339
+    /**
340
+     * Sets the additivity flag.
341
+     * @param boolean $additive
342
+     */
343
+    public function setAdditivity($additive) {
344
+        $this->additive = (bool)$additive;
345
+    }
346
+	
347
+    /**
348
+     * Returns the additivity flag.
349
+     * @return boolean
350
+     */
351
+    public function getAdditivity() {
352
+        return $this->additive;
353
+    }
354 354
  
355
-	/**
356
-	 * Starting from this Logger, search the Logger hierarchy for a non-null level and return it.
357
-	 * @see LoggerLevel
358
-	 * @return Payone_Log4php_LoggerLevel or null
359
-	 */
360
-	public function getEffectiveLevel() {
361
-		for($logger = $this; $logger !== null; $logger = $logger->getParent()) {
362
-			if($logger->getLevel() !== null) {
363
-				return $logger->getLevel();
364
-			}
365
-		}
366
-	}
355
+    /**
356
+     * Starting from this Logger, search the Logger hierarchy for a non-null level and return it.
357
+     * @see LoggerLevel
358
+     * @return Payone_Log4php_LoggerLevel or null
359
+     */
360
+    public function getEffectiveLevel() {
361
+        for($logger = $this; $logger !== null; $logger = $logger->getParent()) {
362
+            if($logger->getLevel() !== null) {
363
+                return $logger->getLevel();
364
+            }
365
+        }
366
+    }
367 367
   
368
-	/**
369
-	 * Get the assigned Logger level.
370
-	 * @return Payone_Log4php_LoggerLevel The assigned level or null if none is assigned.
371
-	 */
372
-	public function getLevel() {
373
-		return $this->level;
374
-	}
375
-	
376
-	/**
377
-	 * Set the Logger level.
378
-	 *
379
-	 * @param Payone_Log4php_LoggerLevel $level the level to set
380
-	 */
381
-	public function setLevel($level) {
382
-		$this->level = $level;
383
-	}
384
-	
385
-	/**
386
-	 * Checks whether an appender is attached to this logger instance.
387
-	 *
388
-	 * @param Payone_Log4php_LoggerAppender $appender
389
-	 * @return boolean
390
-	 */
391
-	public function isAttached(Payone_Log4php_LoggerAppender $appender) {
392
-		return isset($this->appenders[$appender->getName()]);
393
-	} 
368
+    /**
369
+     * Get the assigned Logger level.
370
+     * @return Payone_Log4php_LoggerLevel The assigned level or null if none is assigned.
371
+     */
372
+    public function getLevel() {
373
+        return $this->level;
374
+    }
375
+	
376
+    /**
377
+     * Set the Logger level.
378
+     *
379
+     * @param Payone_Log4php_LoggerLevel $level the level to set
380
+     */
381
+    public function setLevel($level) {
382
+        $this->level = $level;
383
+    }
384
+	
385
+    /**
386
+     * Checks whether an appender is attached to this logger instance.
387
+     *
388
+     * @param Payone_Log4php_LoggerAppender $appender
389
+     * @return boolean
390
+     */
391
+    public function isAttached(Payone_Log4php_LoggerAppender $appender) {
392
+        return isset($this->appenders[$appender->getName()]);
393
+    } 
394 394
 		   
395 395
 
396
-	/**
397
-	 * Sets the parent logger.
398
-	 * @param Logger $logger
399
-	 */
400
-	public function setParent(Payone_Log4php_Logger $logger) {
401
-		$this->parent = $logger;
402
-	} 
403
-	
404
-	// ******************************************
405
-	// *** Static methods and properties      ***
406
-	// ******************************************
407
-	
408
-	/** The logger hierarchy used by log4php. */
409
-	private static $hierarchy;
410
-	
411
-	/** Inidicates if log4php has been initialized */
412
-	private static $initialized = false;
413
-	
414
-	/**
415
-	 * Returns the hierarchy used by this Logger.
416
-	 *
417
-	 * Caution: do not use this hierarchy unless you have called initialize().
418
-	 * To get Loggers, use the Logger::getLogger and Logger::getRootLogger
419
-	 * methods instead of operating on on the hierarchy directly.
420
-	 *
421
-	 * @return Payone_Log4php_LoggerHierarchy
422
-	 */
423
-	public static function getHierarchy() {
424
-		if(!isset(self::$hierarchy)) {
425
-			self::$hierarchy = new Payone_Log4php_LoggerHierarchy(new Payone_Log4php_LoggerRoot());
426
-		}
427
-		return self::$hierarchy;
428
-	}
429
-	
430
-	/**
431
-	 * Returns a Logger by name. If it does not exist, it will be created.
432
-	 *
433
-	 * @param string $name The logger name
434
-	 * @return Logger
435
-	 */
436
-	public static function getLogger($name) {
437
-		if(!self::isInitialized()) {
438
-			self::configure();
439
-		}
440
-		return self::getHierarchy()->getLogger($name);
441
-	}
442
-	
443
-	/**
444
-	 * Returns the Root Logger.
445
-	 * @return Payone_Log4php_LoggerRoot
446
-	 */
447
-	public static function getRootLogger() {
448
-		if(!self::isInitialized()) {
449
-			self::configure();
450
-		}
451
-		return self::getHierarchy()->getRootLogger();
452
-	}
453
-	
454
-	/**
455
-	 * Clears all Logger definitions from the logger hierarchy.
456
-	 * @return boolean
457
-	 */
458
-	public static function clear() {
459
-		return self::getHierarchy()->clear();
460
-	}
461
-	
462
-	/**
463
-	 * Destroy configurations for logger definitions
464
-	 */
465
-	public static function resetConfiguration() {
466
-		self::getHierarchy()->resetConfiguration();
467
-		self::getHierarchy()->clear(); // TODO: clear or not?
468
-		self::$initialized = false;
469
-	}
470
-	
471
-	/**
472
-	 * Safely close all appenders.
473
-	 * @deprecated This is no longer necessary due the appenders shutdown via
474
-	 * destructors.
475
-	 */
476
-	public static function shutdown() {
477
-		return self::getHierarchy()->shutdown();
478
-	}
479
-	
480
-	/**
481
-	 * check if a given logger exists.
482
-	 *
483
-	 * @param string $name logger name
484
-	 * @return boolean
485
-	 */
486
-	public static function exists($name) {
487
-		return self::getHierarchy()->exists($name);
488
-	}
489
-	
490
-	/**
491
-	 * Returns an array this whole Logger instances.
492
-	 * @see Logger
493
-	 * @return array
494
-	 */
495
-	public static function getCurrentLoggers() {
496
-		return self::getHierarchy()->getCurrentLoggers();
497
-	}
498
-	
499
-	/**
500
-	 * Configures log4php.
501
-	 * 
502
-	 * This method needs to be called before the first logging event has 
503
-	 * occured. If this method is not called before then the default
504
-	 * configuration will be used.
505
-	 *
506
-	 * @param string|array $configuration Either a path to the configuration
507
-	 *   file, or a configuration array.
508
-	 *   
509
-	 * @param string|LoggerConfigurator $configurator A custom 
510
-	 * configurator class: either a class name (string), or an object which 
511
-	 * implements the LoggerConfigurator interface. If left empty, the default
512
-	 * configurator implementation will be used. 
513
-	 */
514
-	public static function configure($configuration = null, $configurator = null) {
515
-		self::resetConfiguration();
516
-		$configurator = self::getConfigurator($configurator);
517
-		$configurator->configure(self::getHierarchy(), $configuration);
518
-		self::$initialized = true;
519
-	}
520
-	
521
-	/**
522
-	 * Creates a logger configurator instance based on the provided 
523
-	 * configurator class. If no class is given, returns an instance of
524
-	 * the default configurator.
525
-	 * 
526
-	 * @param string|LoggerConfigurator $configurator The configurator class 
527
-	 * or LoggerConfigurator instance.
528
-	 */
529
-	private static function getConfigurator($configurator = null) {
530
-		if ($configurator === null) {
531
-			return new Payone_Log4php_LoggerConfiguratorDefault();
532
-		}
396
+    /**
397
+     * Sets the parent logger.
398
+     * @param Logger $logger
399
+     */
400
+    public function setParent(Payone_Log4php_Logger $logger) {
401
+        $this->parent = $logger;
402
+    } 
403
+	
404
+    // ******************************************
405
+    // *** Static methods and properties      ***
406
+    // ******************************************
407
+	
408
+    /** The logger hierarchy used by log4php. */
409
+    private static $hierarchy;
410
+	
411
+    /** Inidicates if log4php has been initialized */
412
+    private static $initialized = false;
413
+	
414
+    /**
415
+     * Returns the hierarchy used by this Logger.
416
+     *
417
+     * Caution: do not use this hierarchy unless you have called initialize().
418
+     * To get Loggers, use the Logger::getLogger and Logger::getRootLogger
419
+     * methods instead of operating on on the hierarchy directly.
420
+     *
421
+     * @return Payone_Log4php_LoggerHierarchy
422
+     */
423
+    public static function getHierarchy() {
424
+        if(!isset(self::$hierarchy)) {
425
+            self::$hierarchy = new Payone_Log4php_LoggerHierarchy(new Payone_Log4php_LoggerRoot());
426
+        }
427
+        return self::$hierarchy;
428
+    }
429
+	
430
+    /**
431
+     * Returns a Logger by name. If it does not exist, it will be created.
432
+     *
433
+     * @param string $name The logger name
434
+     * @return Logger
435
+     */
436
+    public static function getLogger($name) {
437
+        if(!self::isInitialized()) {
438
+            self::configure();
439
+        }
440
+        return self::getHierarchy()->getLogger($name);
441
+    }
442
+	
443
+    /**
444
+     * Returns the Root Logger.
445
+     * @return Payone_Log4php_LoggerRoot
446
+     */
447
+    public static function getRootLogger() {
448
+        if(!self::isInitialized()) {
449
+            self::configure();
450
+        }
451
+        return self::getHierarchy()->getRootLogger();
452
+    }
453
+	
454
+    /**
455
+     * Clears all Logger definitions from the logger hierarchy.
456
+     * @return boolean
457
+     */
458
+    public static function clear() {
459
+        return self::getHierarchy()->clear();
460
+    }
461
+	
462
+    /**
463
+     * Destroy configurations for logger definitions
464
+     */
465
+    public static function resetConfiguration() {
466
+        self::getHierarchy()->resetConfiguration();
467
+        self::getHierarchy()->clear(); // TODO: clear or not?
468
+        self::$initialized = false;
469
+    }
470
+	
471
+    /**
472
+     * Safely close all appenders.
473
+     * @deprecated This is no longer necessary due the appenders shutdown via
474
+     * destructors.
475
+     */
476
+    public static function shutdown() {
477
+        return self::getHierarchy()->shutdown();
478
+    }
479
+	
480
+    /**
481
+     * check if a given logger exists.
482
+     *
483
+     * @param string $name logger name
484
+     * @return boolean
485
+     */
486
+    public static function exists($name) {
487
+        return self::getHierarchy()->exists($name);
488
+    }
489
+	
490
+    /**
491
+     * Returns an array this whole Logger instances.
492
+     * @see Logger
493
+     * @return array
494
+     */
495
+    public static function getCurrentLoggers() {
496
+        return self::getHierarchy()->getCurrentLoggers();
497
+    }
498
+	
499
+    /**
500
+     * Configures log4php.
501
+     * 
502
+     * This method needs to be called before the first logging event has 
503
+     * occured. If this method is not called before then the default
504
+     * configuration will be used.
505
+     *
506
+     * @param string|array $configuration Either a path to the configuration
507
+     *   file, or a configuration array.
508
+     *   
509
+     * @param string|LoggerConfigurator $configurator A custom 
510
+     * configurator class: either a class name (string), or an object which 
511
+     * implements the LoggerConfigurator interface. If left empty, the default
512
+     * configurator implementation will be used. 
513
+     */
514
+    public static function configure($configuration = null, $configurator = null) {
515
+        self::resetConfiguration();
516
+        $configurator = self::getConfigurator($configurator);
517
+        $configurator->configure(self::getHierarchy(), $configuration);
518
+        self::$initialized = true;
519
+    }
520
+	
521
+    /**
522
+     * Creates a logger configurator instance based on the provided 
523
+     * configurator class. If no class is given, returns an instance of
524
+     * the default configurator.
525
+     * 
526
+     * @param string|LoggerConfigurator $configurator The configurator class 
527
+     * or LoggerConfigurator instance.
528
+     */
529
+    private static function getConfigurator($configurator = null) {
530
+        if ($configurator === null) {
531
+            return new Payone_Log4php_LoggerConfiguratorDefault();
532
+        }
533 533
 		
534
-		if (is_object($configurator)) {
535
-			if ($configurator instanceof Payone_Log4php_LoggerConfigurator) {
536
-				return $configurator;
537
-			} else {
538
-				trigger_error("log4php: Given configurator object [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING);
539
-				return new Payone_Log4php_LoggerConfiguratorDefault();
540
-			}
541
-		}
534
+        if (is_object($configurator)) {
535
+            if ($configurator instanceof Payone_Log4php_LoggerConfigurator) {
536
+                return $configurator;
537
+            } else {
538
+                trigger_error("log4php: Given configurator object [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING);
539
+                return new Payone_Log4php_LoggerConfiguratorDefault();
540
+            }
541
+        }
542 542
 		
543
-		if (is_string($configurator)) {
544
-			if (!class_exists($configurator)) {
545
-				trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING);
546
-				return new Payone_Log4php_LoggerConfiguratorDefault();
547
-			}
543
+        if (is_string($configurator)) {
544
+            if (!class_exists($configurator)) {
545
+                trigger_error("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING);
546
+                return new Payone_Log4php_LoggerConfiguratorDefault();
547
+            }
548 548
 			
549
-			$instance = new $configurator();
549
+            $instance = new $configurator();
550 550
 				
551
-			if (!($instance instanceof Payone_Log4php_LoggerConfigurator)) {
552
-				trigger_error("log4php: Specified configurator class [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING);
553
-				return new Payone_Log4php_LoggerConfiguratorDefault();
554
-			}
551
+            if (!($instance instanceof Payone_Log4php_LoggerConfigurator)) {
552
+                trigger_error("log4php: Specified configurator class [$configurator] does not implement the LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING);
553
+                return new Payone_Log4php_LoggerConfiguratorDefault();
554
+            }
555 555
 			
556
-			return $instance;
557
-		}
556
+            return $instance;
557
+        }
558 558
 		
559
-		trigger_error("log4php: Invalid configurator specified. Expected either a string or a LoggerConfigurator instance. Reverting to default configurator.", E_USER_WARNING);
560
-		return new Payone_Log4php_LoggerConfiguratorDefault();
561
-	}
562
-	
563
-	/**
564
-	 * Returns true if the log4php framework has been initialized.
565
-	 * @return boolean 
566
-	 */
567
-	private static function isInitialized() {
568
-		return self::$initialized;
569
-	}
559
+        trigger_error("log4php: Invalid configurator specified. Expected either a string or a LoggerConfigurator instance. Reverting to default configurator.", E_USER_WARNING);
560
+        return new Payone_Log4php_LoggerConfiguratorDefault();
561
+    }
562
+	
563
+    /**
564
+     * Returns true if the log4php framework has been initialized.
565
+     * @return boolean 
566
+     */
567
+    private static function isInitialized() {
568
+        return self::$initialized;
569
+    }
570 570
 	
571 571
 }
Please login to merge, or discard this 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/LoggerConfigurationAdapterXML.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -69,6 +69,7 @@  discard block
 block discarded – undo
69 69
 	/**
70 70
 	 * Loads and validates the XML.
71 71
 	 * @param string $url Input XML.
72
+	 * @return SimpleXMLElement
72 73
 	 */
73 74
 	private function loadXML($url) {
74 75
 		if (!file_exists($url)) {
@@ -213,6 +214,7 @@  discard block
 block discarded – undo
213 214
 	
214 215
 	/** 
215 216
 	 * Parses a <logger> node for appender references and returns them in an array.
217
+	 * @param string $name
216 218
 	 */
217 219
 	private function parseAppenderReferences(SimpleXMLElement $node, $name) {
218 220
 		$refs = array();
@@ -247,6 +249,9 @@  discard block
 block discarded – undo
247 249
 	// ** Helper methods                       **
248 250
 	// ******************************************
249 251
 	
252
+	/**
253
+	 * @param string $name
254
+	 */
250 255
 	private function getAttributeValue(SimpleXMLElement $node, $name) {
251 256
 		return isset($node[$name]) ? (string) $node[$name] : null;
252 257
 	}
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -29,231 +29,231 @@
 block discarded – undo
29 29
  */
30 30
 class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
31 31
 {
32
-	/** Path to the XML schema used for validation. */
33
-	const SCHEMA_PATH = '/../xml/log4php.xsd';
32
+    /** Path to the XML schema used for validation. */
33
+    const SCHEMA_PATH = '/../xml/log4php.xsd';
34 34
 	
35
-	private $config = array(
36
-		'appenders' => array(),
37
-		'loggers' => array(),
38
-		'renderers' => array(),
39
-	);
35
+    private $config = array(
36
+        'appenders' => array(),
37
+        'loggers' => array(),
38
+        'renderers' => array(),
39
+    );
40 40
 	
41
-	public function convert($url)
42
-	{
43
-		$xml = $this->loadXML($url);
41
+    public function convert($url)
42
+    {
43
+        $xml = $this->loadXML($url);
44 44
 		
45
-		$this->parseConfiguration($xml);
45
+        $this->parseConfiguration($xml);
46 46
 
47
-		// Parse the <root> node
48
-		if (isset($xml->root)) {		
49
-			$this->parseRootLogger($xml->root);
50
-		}
47
+        // Parse the <root> node
48
+        if (isset($xml->root)) {		
49
+            $this->parseRootLogger($xml->root);
50
+        }
51 51
 		
52
-		// Process <logger> nodes
53
-		foreach($xml->logger as $logger) {
54
-			$this->parseLogger($logger);
55
-		} 
52
+        // Process <logger> nodes
53
+        foreach($xml->logger as $logger) {
54
+            $this->parseLogger($logger);
55
+        } 
56 56
 		
57
-		// Process <appender> nodes
58
-		foreach($xml->appender as $appender) {
59
-			$this->parseAppender($appender);
60
-		}
57
+        // Process <appender> nodes
58
+        foreach($xml->appender as $appender) {
59
+            $this->parseAppender($appender);
60
+        }
61 61
 		
62
-		// Process <renderer> nodes
63
-		foreach($xml->renderer as $rendererNode) {
64
-			$this->parseRenderer($rendererNode);
65
-		}
66
-		return $this->config;
67
-	}
62
+        // Process <renderer> nodes
63
+        foreach($xml->renderer as $rendererNode) {
64
+            $this->parseRenderer($rendererNode);
65
+        }
66
+        return $this->config;
67
+    }
68 68
 	
69
-	/**
70
-	 * Loads and validates the XML.
71
-	 * @param string $url Input XML.
72
-	 */
73
-	private function loadXML($url) {
74
-		if (!file_exists($url)) {
75
-			throw new Payone_Log4php_LoggerException("File [$url] does not exist.");
76
-		}
69
+    /**
70
+     * Loads and validates the XML.
71
+     * @param string $url Input XML.
72
+     */
73
+    private function loadXML($url) {
74
+        if (!file_exists($url)) {
75
+            throw new Payone_Log4php_LoggerException("File [$url] does not exist.");
76
+        }
77 77
 
78
-		libxml_clear_errors();
79
-		$oldValue = libxml_use_internal_errors(true);
78
+        libxml_clear_errors();
79
+        $oldValue = libxml_use_internal_errors(true);
80 80
 		
81
-		// Load XML
82
-		$xml = @simplexml_load_file($url);
83
-		if ($xml === false) {
81
+        // Load XML
82
+        $xml = @simplexml_load_file($url);
83
+        if ($xml === false) {
84 84
 			
85
-			$errorStr = "";
86
-			foreach(libxml_get_errors() as $error) {
87
-				$errorStr .= $error->message;
88
-			}
85
+            $errorStr = "";
86
+            foreach(libxml_get_errors() as $error) {
87
+                $errorStr .= $error->message;
88
+            }
89 89
 			
90
-			throw new Payone_Log4php_LoggerException("Error loading configuration file: " . trim($errorStr));
91
-		}
90
+            throw new Payone_Log4php_LoggerException("Error loading configuration file: " . trim($errorStr));
91
+        }
92 92
 		
93
-		libxml_clear_errors();
94
-		libxml_use_internal_errors($oldValue);
93
+        libxml_clear_errors();
94
+        libxml_use_internal_errors($oldValue);
95 95
 		
96
-		return $xml;
97
-	}
96
+        return $xml;
97
+    }
98 98
 	
99
-	/**
100
-	 * Parses the <configuration> node.
101
-	 */
102
-	private function parseConfiguration(SimpleXMLElement $xml) {
103
-		$attributes = $xml->attributes();
104
-		if (isset($attributes['threshold'])) {
105
-			$this->config['threshold'] = (string) $attributes['threshold'];
106
-		}
107
-	}
99
+    /**
100
+     * Parses the <configuration> node.
101
+     */
102
+    private function parseConfiguration(SimpleXMLElement $xml) {
103
+        $attributes = $xml->attributes();
104
+        if (isset($attributes['threshold'])) {
105
+            $this->config['threshold'] = (string) $attributes['threshold'];
106
+        }
107
+    }
108 108
 	
109
-	/** Parses an <appender> node. */
110
-	private function parseAppender(SimpleXMLElement $node) {
111
-		$name = $this->getAttributeValue($node, 'name');
112
-		if (empty($name)) {
113
-			$this->warn("An <appender> node is missing the required 'name' attribute. Skipping appender definition.");
114
-			return;
115
-		}
109
+    /** Parses an <appender> node. */
110
+    private function parseAppender(SimpleXMLElement $node) {
111
+        $name = $this->getAttributeValue($node, 'name');
112
+        if (empty($name)) {
113
+            $this->warn("An <appender> node is missing the required 'name' attribute. Skipping appender definition.");
114
+            return;
115
+        }
116 116
 		
117
-		$appender = array();
118
-		$appender['class'] = $this->getAttributeValue($node, 'class');
117
+        $appender = array();
118
+        $appender['class'] = $this->getAttributeValue($node, 'class');
119 119
 		
120
-		if (isset($node['threshold'])) {
121
-			$appender['threshold'] = $this->getAttributeValue($node, 'threshold');
122
-		}
120
+        if (isset($node['threshold'])) {
121
+            $appender['threshold'] = $this->getAttributeValue($node, 'threshold');
122
+        }
123 123
 		
124
-		if (isset($node->layout)) {
125
-			$appender['layout']= $this->parseLayout($node->layout, $name);
126
-		}
124
+        if (isset($node->layout)) {
125
+            $appender['layout']= $this->parseLayout($node->layout, $name);
126
+        }
127 127
 		
128
-		if (count($node->param) > 0) {
129
-			$appender['params'] = $this->parseParameters($node);
130
-		}
128
+        if (count($node->param) > 0) {
129
+            $appender['params'] = $this->parseParameters($node);
130
+        }
131 131
 		
132
-		foreach($node->filter as $filterNode) {
133
-			$appender['filters'][] = $this->parseFilter($filterNode);
134
-		}
132
+        foreach($node->filter as $filterNode) {
133
+            $appender['filters'][] = $this->parseFilter($filterNode);
134
+        }
135 135
 		
136
-		$this->config['appenders'][$name] = $appender;
137
-	}
136
+        $this->config['appenders'][$name] = $appender;
137
+    }
138 138
 	
139
-	/** Parses a <layout> node. */
140
-	private function parseLayout(SimpleXMLElement $node, $appenderName) {
141
-		$layout = array();
142
-		$layout['class'] = $this->getAttributeValue($node, 'class');
139
+    /** Parses a <layout> node. */
140
+    private function parseLayout(SimpleXMLElement $node, $appenderName) {
141
+        $layout = array();
142
+        $layout['class'] = $this->getAttributeValue($node, 'class');
143 143
 		
144
-		if (count($node->param) > 0) {
145
-			$layout['params'] = $this->parseParameters($node);
146
-		}
144
+        if (count($node->param) > 0) {
145
+            $layout['params'] = $this->parseParameters($node);
146
+        }
147 147
 		
148
-		return $layout;
149
-	}
148
+        return $layout;
149
+    }
150 150
 
151
-	/** Parses any <param> child nodes returning them in an array. */
152
-	private function parseParameters($paramsNode) {
153
-		$params = array();
151
+    /** Parses any <param> child nodes returning them in an array. */
152
+    private function parseParameters($paramsNode) {
153
+        $params = array();
154 154
 
155
-		foreach($paramsNode->param as $paramNode) {
156
-			if (empty($paramNode['name'])) {
157
-				$this->warn("A <param> node is missing the required 'name' attribute. Skipping parameter.");
158
-				continue;
159
-			}
155
+        foreach($paramsNode->param as $paramNode) {
156
+            if (empty($paramNode['name'])) {
157
+                $this->warn("A <param> node is missing the required 'name' attribute. Skipping parameter.");
158
+                continue;
159
+            }
160 160
 			
161
-			$name = $this->getAttributeValue($paramNode, 'name');
162
-			$value = $this->getAttributeValue($paramNode, 'value');
161
+            $name = $this->getAttributeValue($paramNode, 'name');
162
+            $value = $this->getAttributeValue($paramNode, 'value');
163 163
 			
164
-			$params[$name] = $value;
165
-		}
164
+            $params[$name] = $value;
165
+        }
166 166
 
167
-		return $params;
168
-	}
167
+        return $params;
168
+    }
169 169
 	
170
-	/** Parses a <root> node. */
171
-	private function parseRootLogger(SimpleXMLElement $node) {
172
-		$logger = array();
170
+    /** Parses a <root> node. */
171
+    private function parseRootLogger(SimpleXMLElement $node) {
172
+        $logger = array();
173 173
 		
174
-		if (isset($node->level)) {
175
-			$logger['level'] = $this->getAttributeValue($node->level, 'value');
176
-		}
174
+        if (isset($node->level)) {
175
+            $logger['level'] = $this->getAttributeValue($node->level, 'value');
176
+        }
177 177
 		
178
-		$logger['appenders'] = array();
179
-		foreach($node->appender_ref as $appender) {
180
-			$logger['appenders'][] = $this->getAttributeValue($appender, 'ref');
181
-		}
178
+        $logger['appenders'] = array();
179
+        foreach($node->appender_ref as $appender) {
180
+            $logger['appenders'][] = $this->getAttributeValue($appender, 'ref');
181
+        }
182 182
 		
183
-		$this->config['rootLogger'] = $logger;
184
-	}
183
+        $this->config['rootLogger'] = $logger;
184
+    }
185 185
 	
186
-	/** Parses a <logger> node. */
187
-	private function parseLogger(SimpleXMLElement $node) {
188
-		$logger = array();
186
+    /** Parses a <logger> node. */
187
+    private function parseLogger(SimpleXMLElement $node) {
188
+        $logger = array();
189 189
 		
190
-		$name = $this->getAttributeValue($node, 'name');
191
-		if (empty($name)) {
192
-			$this->warn("A <logger> node is missing the required 'name' attribute. Skipping logger definition.");
193
-			return;
194
-		}
190
+        $name = $this->getAttributeValue($node, 'name');
191
+        if (empty($name)) {
192
+            $this->warn("A <logger> node is missing the required 'name' attribute. Skipping logger definition.");
193
+            return;
194
+        }
195 195
 		
196
-		if (isset($node->level)) {
197
-			$logger['level'] = $this->getAttributeValue($node->level, 'value');
198
-		}
196
+        if (isset($node->level)) {
197
+            $logger['level'] = $this->getAttributeValue($node->level, 'value');
198
+        }
199 199
 		
200
-		if (isset($node['additivity'])) {
201
-			$logger['additivity'] = $this->getAttributeValue($node, 'additivity');
202
-		}
200
+        if (isset($node['additivity'])) {
201
+            $logger['additivity'] = $this->getAttributeValue($node, 'additivity');
202
+        }
203 203
 		
204
-		$logger['appenders'] = $this->parseAppenderReferences($node, $name);
204
+        $logger['appenders'] = $this->parseAppenderReferences($node, $name);
205 205
 
206
-		// Check for duplicate loggers
207
-		if (isset($this->config['loggers'][$name])) {
208
-			$this->warn("Duplicate logger definition [$name]. Overwriting.");
209
-		}
206
+        // Check for duplicate loggers
207
+        if (isset($this->config['loggers'][$name])) {
208
+            $this->warn("Duplicate logger definition [$name]. Overwriting.");
209
+        }
210 210
 		
211
-		$this->config['loggers'][$name] = $logger;
212
-	}
211
+        $this->config['loggers'][$name] = $logger;
212
+    }
213 213
 	
214
-	/** 
215
-	 * Parses a <logger> node for appender references and returns them in an array.
216
-	 */
217
-	private function parseAppenderReferences(SimpleXMLElement $node, $name) {
218
-		$refs = array();
219
-		foreach($node->appender_ref as $ref) {
220
-			$refs[] = $this->getAttributeValue($ref, 'ref');
221
-		}
214
+    /** 
215
+     * Parses a <logger> node for appender references and returns them in an array.
216
+     */
217
+    private function parseAppenderReferences(SimpleXMLElement $node, $name) {
218
+        $refs = array();
219
+        foreach($node->appender_ref as $ref) {
220
+            $refs[] = $this->getAttributeValue($ref, 'ref');
221
+        }
222 222
 		
223
-		return $refs;
224
-	}
223
+        return $refs;
224
+    }
225 225
 	
226
-	/** Parses a <filter> node. */
227
-	private function parseFilter($filterNode) {
228
-		$filter = array();
229
-		$filter['class'] = $this->getAttributeValue($filterNode, 'class');
226
+    /** Parses a <filter> node. */
227
+    private function parseFilter($filterNode) {
228
+        $filter = array();
229
+        $filter['class'] = $this->getAttributeValue($filterNode, 'class');
230 230
 		
231
-		if (count($filterNode->param) > 0) {
232
-			$filter['params'] = $this->parseParameters($filterNode);
233
-		}
231
+        if (count($filterNode->param) > 0) {
232
+            $filter['params'] = $this->parseParameters($filterNode);
233
+        }
234 234
 		
235
-		return $filter;
236
-	}
235
+        return $filter;
236
+    }
237 237
 	
238
-	/** Parses a <renderer> node. */
239
-	private function parseRenderer(SimpleXMLElement $node) {
240
-		$renderedClass = $this->getAttributeValue($node, 'renderedClass');
241
-		$renderingClass = $this->getAttributeValue($node, 'renderingClass');
238
+    /** Parses a <renderer> node. */
239
+    private function parseRenderer(SimpleXMLElement $node) {
240
+        $renderedClass = $this->getAttributeValue($node, 'renderedClass');
241
+        $renderingClass = $this->getAttributeValue($node, 'renderingClass');
242 242
 		
243
-		$this->config['renderers'][] = compact('renderedClass', 'renderingClass');
244
-	}
243
+        $this->config['renderers'][] = compact('renderedClass', 'renderingClass');
244
+    }
245 245
 	
246
-	// ******************************************
247
-	// ** Helper methods                       **
248
-	// ******************************************
246
+    // ******************************************
247
+    // ** Helper methods                       **
248
+    // ******************************************
249 249
 	
250
-	private function getAttributeValue(SimpleXMLElement $node, $name) {
251
-		return isset($node[$name]) ? (string) $node[$name] : null;
252
-	}
250
+    private function getAttributeValue(SimpleXMLElement $node, $name) {
251
+        return isset($node[$name]) ? (string) $node[$name] : null;
252
+    }
253 253
 	
254
-	private function warn($message) {
255
-		trigger_error("log4php: " . $message, E_USER_WARNING);
256
-	}
254
+    private function warn($message) {
255
+        trigger_error("log4php: " . $message, E_USER_WARNING);
256
+    }
257 257
 }
258 258
 
259 259
 ?>
260 260
\ No newline at end of file
Please login to merge, or discard this 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/LoggerConfiguratorDefault.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -404,7 +404,7 @@
 block discarded – undo
404 404
 	/**
405 405
 	 * Configures a logger. 
406 406
 	 * 
407
-	 * @param Logger $logger The logger to configure
407
+	 * @param Payone_Log4php_Logger $logger The logger to configure
408 408
 	 * @param array $config Logger configuration options.
409 409
 	 */
410 410
 	private function configureLogger(Payone_Log4php_Logger $logger, $config) {
Please login to merge, or discard this patch.
Indentation   +382 added lines, -382 removed lines patch added patch discarded remove patch
@@ -30,24 +30,24 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class Payone_Log4php_LoggerConfiguratorDefault implements Payone_Log4php_LoggerConfigurator
32 32
 {
33
-	/** XML configuration file format. */
34
-	const FORMAT_XML = 'xml';
33
+    /** XML configuration file format. */
34
+    const FORMAT_XML = 'xml';
35 35
 	
36
-	/** PHP configuration file format. */
37
-	const FORMAT_PHP = 'php';
36
+    /** PHP configuration file format. */
37
+    const FORMAT_PHP = 'php';
38 38
 	
39
-	/** INI (properties) configuration file format. */
40
-	const FORMAT_INI = 'ini';
39
+    /** INI (properties) configuration file format. */
40
+    const FORMAT_INI = 'ini';
41 41
 
42
-	/** Defines which adapter should be used for parsing which format. */
43
-	private $adapters = array(
44
-		self::FORMAT_XML => 'Payone_Log4php_LoggerConfigurationAdapterXML',
45
-		self::FORMAT_INI => 'Payone_Log4php_LoggerConfigurationAdapterINI',
46
-		self::FORMAT_PHP => 'Payone_Log4php_LoggerConfigurationAdapterPHP',
47
-	);
42
+    /** Defines which adapter should be used for parsing which format. */
43
+    private $adapters = array(
44
+        self::FORMAT_XML => 'Payone_Log4php_LoggerConfigurationAdapterXML',
45
+        self::FORMAT_INI => 'Payone_Log4php_LoggerConfigurationAdapterINI',
46
+        self::FORMAT_PHP => 'Payone_Log4php_LoggerConfigurationAdapterPHP',
47
+    );
48 48
 	
49
-	/** Default configuration; used if no configuration file is provided. */
50
-	private static $defaultConfiguration = array(
49
+    /** Default configuration; used if no configuration file is provided. */
50
+    private static $defaultConfiguration = array(
51 51
         'threshold' => 'ALL',
52 52
         'rootLogger' => array(
53 53
             'level' => 'DEBUG',
@@ -61,425 +61,425 @@  discard block
 block discarded – undo
61 61
                 ),
62 62
             ),
63 63
         ),
64
-	);
64
+    );
65 65
 	
66
-	/** Holds the appenders before they are linked to loggers. */
67
-	private $appenders = array();
66
+    /** Holds the appenders before they are linked to loggers. */
67
+    private $appenders = array();
68 68
 	
69
-	/**
70
-	 * Configures log4php based on the given configuration. The input can 
71
-	 * either be a path to the config file, or a PHP array holding the 
72
-	 * configuration. 
73
-	 * 
74
-	 * If no configuration is given, or if the given configuration cannot be
75
-	 * parsed for whatever reason, a warning will be issued, and log4php
76
-	 * will use the default configuration contained in 
77
-	 * {@link $defaultConfiguration}.
78
-	 * 
79
-	 * @param Payone_Log4php_LoggerHierarchy $hierarchy The hierarchy on which to perform
80
-	 * 		the configuration. 
81
-	 * @param string|array $input Either path to the config file or the 
82
-	 * 		configuration as an array. If not set, default configuration 
83
-	 * 		will be used.
84
-	 */
85
-	public function configure(Payone_Log4php_LoggerHierarchy $hierarchy, $input = null) {
86
-		$config = $this->parse($input);
87
-		$this->doConfigure($hierarchy, $config);
88
-	}
69
+    /**
70
+     * Configures log4php based on the given configuration. The input can 
71
+     * either be a path to the config file, or a PHP array holding the 
72
+     * configuration. 
73
+     * 
74
+     * If no configuration is given, or if the given configuration cannot be
75
+     * parsed for whatever reason, a warning will be issued, and log4php
76
+     * will use the default configuration contained in 
77
+     * {@link $defaultConfiguration}.
78
+     * 
79
+     * @param Payone_Log4php_LoggerHierarchy $hierarchy The hierarchy on which to perform
80
+     * 		the configuration. 
81
+     * @param string|array $input Either path to the config file or the 
82
+     * 		configuration as an array. If not set, default configuration 
83
+     * 		will be used.
84
+     */
85
+    public function configure(Payone_Log4php_LoggerHierarchy $hierarchy, $input = null) {
86
+        $config = $this->parse($input);
87
+        $this->doConfigure($hierarchy, $config);
88
+    }
89 89
 	
90
-	/**
91
-	 * Parses the given configuration and returns the parsed configuration
92
-	 * as a PHP array. Does not perform any configuration. 
93
-	 * 
94
-	 * If no configuration is given, or if the given configuration cannot be
95
-	 * parsed for whatever reason, a warning will be issued, and the default 
96
-	 * configuration will be returned ({@link $defaultConfiguration}).
97
-	 * 
98
-	 * @param string|array $input Either path to the config file or the 
99
-	 * 		configuration as an array. If not set, default configuration 
100
-	 * 		will be used.
101
-	 * @return array The parsed configuration.
102
-	 */
103
-	public function parse($input)
104
-	{
105
-		// No input - use default configuration
106
-		if (!isset($input)) {
107
-			$config = self::$defaultConfiguration;
108
-		}
90
+    /**
91
+     * Parses the given configuration and returns the parsed configuration
92
+     * as a PHP array. Does not perform any configuration. 
93
+     * 
94
+     * If no configuration is given, or if the given configuration cannot be
95
+     * parsed for whatever reason, a warning will be issued, and the default 
96
+     * configuration will be returned ({@link $defaultConfiguration}).
97
+     * 
98
+     * @param string|array $input Either path to the config file or the 
99
+     * 		configuration as an array. If not set, default configuration 
100
+     * 		will be used.
101
+     * @return array The parsed configuration.
102
+     */
103
+    public function parse($input)
104
+    {
105
+        // No input - use default configuration
106
+        if (!isset($input)) {
107
+            $config = self::$defaultConfiguration;
108
+        }
109 109
 		
110
-		// Array input - contains configuration within the array
111
-		else if (is_array($input)) {
112
-			$config = $input;
113
-		}
110
+        // Array input - contains configuration within the array
111
+        else if (is_array($input)) {
112
+            $config = $input;
113
+        }
114 114
 		
115
-		// String input - contains path to configuration file
116
-		else if (is_string($input)) {
117
-			try {
118
-				$config = $this->parseFile($input);
119
-			} catch (Payone_Log4php_LoggerException $e) {
120
-				$this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
121
-				$config = self::$defaultConfiguration;
122
-			}
123
-		}
115
+        // String input - contains path to configuration file
116
+        else if (is_string($input)) {
117
+            try {
118
+                $config = $this->parseFile($input);
119
+            } catch (Payone_Log4php_LoggerException $e) {
120
+                $this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
121
+                $config = self::$defaultConfiguration;
122
+            }
123
+        }
124 124
 		
125
-		// Anything else is an error
126
-		else {
127
-			$this->warn("Invalid configuration param given. Reverting to default configuration.");
128
-			$config = self::$defaultConfiguration;
129
-		}
125
+        // Anything else is an error
126
+        else {
127
+            $this->warn("Invalid configuration param given. Reverting to default configuration.");
128
+            $config = self::$defaultConfiguration;
129
+        }
130 130
 		
131
-		return $config;
132
-	}
131
+        return $config;
132
+    }
133 133
 
134
-	/** 
135
-	 * Returns the default log4php configuration.
136
-	 * @return array
137
-	 */
138
-	public static function getDefaultConfiguration() {
139
-		return self::$defaultConfiguration;
140
-	} 
134
+    /** 
135
+     * Returns the default log4php configuration.
136
+     * @return array
137
+     */
138
+    public static function getDefaultConfiguration() {
139
+        return self::$defaultConfiguration;
140
+    } 
141 141
 	
142
-	/**
143
-	 * Loads the configuration file from the given URL, determines which
144
-	 * adapter to use, converts the configuration to a PHP array and
145
-	 * returns it.
146
-	 *
147
-	 * @param string $url Path to the config file.
148
-	 * @return The configuration from the config file, as a PHP array.
149
-	 * @throws LoggerException If the configuration file cannot be loaded, or
150
-	 * 		if the parsing fails.
151
-	 */
152
-	private function parseFile($url) {
142
+    /**
143
+     * Loads the configuration file from the given URL, determines which
144
+     * adapter to use, converts the configuration to a PHP array and
145
+     * returns it.
146
+     *
147
+     * @param string $url Path to the config file.
148
+     * @return The configuration from the config file, as a PHP array.
149
+     * @throws LoggerException If the configuration file cannot be loaded, or
150
+     * 		if the parsing fails.
151
+     */
152
+    private function parseFile($url) {
153 153
 		
154
-		if (!file_exists($url)) {
155
-			throw new Payone_Log4php_LoggerException("File not found at [$url].");
156
-		}
154
+        if (!file_exists($url)) {
155
+            throw new Payone_Log4php_LoggerException("File not found at [$url].");
156
+        }
157 157
 		
158
-		$type = $this->getConfigType($url);
159
-		$adapterClass = $this->adapters[$type];
158
+        $type = $this->getConfigType($url);
159
+        $adapterClass = $this->adapters[$type];
160 160
 
161
-		$adapter = new $adapterClass();
162
-		return $adapter->convert($url);
163
-	}
161
+        $adapter = new $adapterClass();
162
+        return $adapter->convert($url);
163
+    }
164 164
 	
165
-	/** Determines configuration file type based on the file extension. */
166
-	private function getConfigType($url) {
167
-		$info = pathinfo($url);
168
-		$ext = strtolower($info['extension']);
165
+    /** Determines configuration file type based on the file extension. */
166
+    private function getConfigType($url) {
167
+        $info = pathinfo($url);
168
+        $ext = strtolower($info['extension']);
169 169
 		
170
-		switch($ext) {
171
-			case 'xml':
172
-				return self::FORMAT_XML;
170
+        switch($ext) {
171
+            case 'xml':
172
+                return self::FORMAT_XML;
173 173
 			
174
-			case 'ini':
175
-			case 'properties':
176
-				return self::FORMAT_INI;
174
+            case 'ini':
175
+            case 'properties':
176
+                return self::FORMAT_INI;
177 177
 			
178
-			case 'php':
179
-				return self::FORMAT_PHP;
178
+            case 'php':
179
+                return self::FORMAT_PHP;
180 180
 				
181
-			default:
182
-				throw new Payone_Log4php_LoggerException("Unsupported configuration file extension: $ext");
183
-		}
184
-	}
181
+            default:
182
+                throw new Payone_Log4php_LoggerException("Unsupported configuration file extension: $ext");
183
+        }
184
+    }
185 185
 	
186
-	/**
187
-	 * Constructs the logger hierarchy based on configuration.
188
-	 * 
189
-	 * @param Payone_Log4php_LoggerHierarchy $hierarchy
190
-	 * @param array $config
191
-	 */
192
-	private function doConfigure(Payone_Log4php_LoggerHierarchy $hierarchy, $config) {
193
-		if (isset($config['threshold'])) {
194
-			$threshold = Payone_Log4php_LoggerLevel::toLevel($config['threshold']);
195
-			if (isset($threshold)) {
196
-				$hierarchy->setThreshold($threshold);
197
-			} else {
198
-				$this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
199
-			}
200
-		}
186
+    /**
187
+     * Constructs the logger hierarchy based on configuration.
188
+     * 
189
+     * @param Payone_Log4php_LoggerHierarchy $hierarchy
190
+     * @param array $config
191
+     */
192
+    private function doConfigure(Payone_Log4php_LoggerHierarchy $hierarchy, $config) {
193
+        if (isset($config['threshold'])) {
194
+            $threshold = Payone_Log4php_LoggerLevel::toLevel($config['threshold']);
195
+            if (isset($threshold)) {
196
+                $hierarchy->setThreshold($threshold);
197
+            } else {
198
+                $this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
199
+            }
200
+        }
201 201
 		
202
-		// Configure appenders and add them to the appender pool
203
-		if (isset($config['appenders']) && is_array($config['appenders'])) {
204
-			foreach($config['appenders'] as $name => $appenderConfig) {
205
-				$this->configureAppender($name, $appenderConfig);
206
-			}
207
-		}
202
+        // Configure appenders and add them to the appender pool
203
+        if (isset($config['appenders']) && is_array($config['appenders'])) {
204
+            foreach($config['appenders'] as $name => $appenderConfig) {
205
+                $this->configureAppender($name, $appenderConfig);
206
+            }
207
+        }
208 208
 		
209
-		// Configure root logger 
210
-		if (isset($config['rootLogger'])) {
211
-			$this->configureRootLogger($hierarchy, $config['rootLogger']);
212
-		}
209
+        // Configure root logger 
210
+        if (isset($config['rootLogger'])) {
211
+            $this->configureRootLogger($hierarchy, $config['rootLogger']);
212
+        }
213 213
 		
214
-		// Configure loggers
215
-		if (isset($config['loggers']) && is_array($config['loggers'])) {
216
-			foreach($config['loggers'] as $loggerName => $loggerConfig) {
217
-				$this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
218
-			}
219
-		}
214
+        // Configure loggers
215
+        if (isset($config['loggers']) && is_array($config['loggers'])) {
216
+            foreach($config['loggers'] as $loggerName => $loggerConfig) {
217
+                $this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
218
+            }
219
+        }
220 220
 
221
-		// Configure renderers
222
-		if (isset($config['renderers']) && is_array($config['renderers'])) {
223
-			foreach($config['renderers'] as $rendererConfig) {
224
-				$this->configureRenderer($hierarchy, $rendererConfig);
225
-			}
226
-		}
227
-	}
221
+        // Configure renderers
222
+        if (isset($config['renderers']) && is_array($config['renderers'])) {
223
+            foreach($config['renderers'] as $rendererConfig) {
224
+                $this->configureRenderer($hierarchy, $rendererConfig);
225
+            }
226
+        }
227
+    }
228 228
 	
229
-	private function configureRenderer(Payone_Log4php_LoggerHierarchy $hierarchy, $config) {
230
-		if (!isset($config['renderingClass'])) {
231
-			$this->warn("Rendering class not specified. Skipping renderers definition.");
232
-			return;			
233
-		}
229
+    private function configureRenderer(Payone_Log4php_LoggerHierarchy $hierarchy, $config) {
230
+        if (!isset($config['renderingClass'])) {
231
+            $this->warn("Rendering class not specified. Skipping renderers definition.");
232
+            return;			
233
+        }
234 234
 		
235
-		$renderingClass = $config['renderingClass'];
236
-		if (!class_exists($renderingClass)) {
237
-			$this->warn("Nonexistant rendering class [$renderingClass] specified. Skipping renderers definition.");
238
-			return;
239
-		}
235
+        $renderingClass = $config['renderingClass'];
236
+        if (!class_exists($renderingClass)) {
237
+            $this->warn("Nonexistant rendering class [$renderingClass] specified. Skipping renderers definition.");
238
+            return;
239
+        }
240 240
 		
241
-		$renderingClassInstance = new $renderingClass();
242
-		if (!$renderingClassInstance instanceof Payone_Log4php_LoggerRendererObject) {
243
-			$this->warn("Invalid class [$renderingClass] given. Not a valid Payone_Log4php_LoggerRenderer class. Skipping renderers definition.");
244
-			return;			
245
-		}
241
+        $renderingClassInstance = new $renderingClass();
242
+        if (!$renderingClassInstance instanceof Payone_Log4php_LoggerRendererObject) {
243
+            $this->warn("Invalid class [$renderingClass] given. Not a valid Payone_Log4php_LoggerRenderer class. Skipping renderers definition.");
244
+            return;			
245
+        }
246 246
 	
247
-		if (!isset($config['renderedClass'])) {
248
-			$this->warn("Rendered class not specified for rendering Class [$renderingClass]. Skipping renderers definition.");
249
-			return;			
250
-		}
247
+        if (!isset($config['renderedClass'])) {
248
+            $this->warn("Rendered class not specified for rendering Class [$renderingClass]. Skipping renderers definition.");
249
+            return;			
250
+        }
251 251
 		
252
-		$renderedClass = $config['renderedClass'];
253
-		if (!class_exists($renderedClass)) {
254
-			$this->warn("Nonexistant rendered class [$renderedClass] specified for renderer [$renderingClass]. Skipping renderers definition.");
255
-			return;
256
-		}		
252
+        $renderedClass = $config['renderedClass'];
253
+        if (!class_exists($renderedClass)) {
254
+            $this->warn("Nonexistant rendered class [$renderedClass] specified for renderer [$renderingClass]. Skipping renderers definition.");
255
+            return;
256
+        }		
257 257
 
258
-		$hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClassInstance);
259
-	}
258
+        $hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClassInstance);
259
+    }
260 260
 	
261
-	/** 
262
-	 * Configures an appender based on given config and saves it to 
263
-	 * {@link $appenders} array so it can be later linked to loggers. 
264
-	 * @param string $name Appender name. 
265
-	 * @param array $config Appender configuration options.
266
-	 */
267
-	private function configureAppender($name, $config) {
261
+    /** 
262
+     * Configures an appender based on given config and saves it to 
263
+     * {@link $appenders} array so it can be later linked to loggers. 
264
+     * @param string $name Appender name. 
265
+     * @param array $config Appender configuration options.
266
+     */
267
+    private function configureAppender($name, $config) {
268 268
 
269
-		// TODO: add this check to other places where it might be useful
270
-		if (!is_array($config)) {
271
-			$type = gettype($config);
272
-			$this->warn("Invalid configuration provided for appender [$name]. Expected an array, found <$type>. Skipping appender definition.");
273
-			return;
274
-		}
269
+        // TODO: add this check to other places where it might be useful
270
+        if (!is_array($config)) {
271
+            $type = gettype($config);
272
+            $this->warn("Invalid configuration provided for appender [$name]. Expected an array, found <$type>. Skipping appender definition.");
273
+            return;
274
+        }
275 275
 		
276
-		// Parse appender class
277
-		$class = $config['class'];
278
-		if (empty($class)) {
279
-			$this->warn("No class given for appender [$name]. Skipping appender definition.");
280
-			return;
281
-		}
282
-		if (!class_exists($class)) {
283
-			$this->warn("Invalid class [$class] given for appender [$name]. Class does not exist. Skipping appender definition.");
284
-			return;
285
-		}
276
+        // Parse appender class
277
+        $class = $config['class'];
278
+        if (empty($class)) {
279
+            $this->warn("No class given for appender [$name]. Skipping appender definition.");
280
+            return;
281
+        }
282
+        if (!class_exists($class)) {
283
+            $this->warn("Invalid class [$class] given for appender [$name]. Class does not exist. Skipping appender definition.");
284
+            return;
285
+        }
286 286
 		
287
-		// Instantiate the appender
288
-		$appender = new $class($name);
289
-		if (!($appender instanceof Payone_Log4php_LoggerAppender)) {
290
-			$this->warn("Invalid class [$class] given for appender [$name]. Not a valid Payone_Log4php_LoggerAppender class. Skipping appender definition.");
291
-			return;
292
-		}
287
+        // Instantiate the appender
288
+        $appender = new $class($name);
289
+        if (!($appender instanceof Payone_Log4php_LoggerAppender)) {
290
+            $this->warn("Invalid class [$class] given for appender [$name]. Not a valid Payone_Log4php_LoggerAppender class. Skipping appender definition.");
291
+            return;
292
+        }
293 293
 		
294
-		// Parse the appender threshold
295
-		if (isset($config['threshold'])) {
296
-			$threshold = Payone_Log4php_LoggerLevel::toLevel($config['threshold']);
297
-			if ($threshold instanceof Payone_Log4php_LoggerLevel) {
298
-				$appender->setThreshold($threshold);
299
-			} else {
300
-				$this->warn("Invalid threshold value [{$config['threshold']}] specified for appender [$name]. Ignoring threshold definition.");
301
-			}
302
-		}
294
+        // Parse the appender threshold
295
+        if (isset($config['threshold'])) {
296
+            $threshold = Payone_Log4php_LoggerLevel::toLevel($config['threshold']);
297
+            if ($threshold instanceof Payone_Log4php_LoggerLevel) {
298
+                $appender->setThreshold($threshold);
299
+            } else {
300
+                $this->warn("Invalid threshold value [{$config['threshold']}] specified for appender [$name]. Ignoring threshold definition.");
301
+            }
302
+        }
303 303
 		
304
-		// Parse the appender layout
305
-		if ($appender->requiresLayout() && isset($config['layout'])) {
306
-			$this->createAppenderLayout($appender, $config['layout']);
307
-		}
304
+        // Parse the appender layout
305
+        if ($appender->requiresLayout() && isset($config['layout'])) {
306
+            $this->createAppenderLayout($appender, $config['layout']);
307
+        }
308 308
 		
309
-		// Parse filters
310
-		if (isset($config['filters']) && is_array($config['filters'])) {
311
-			foreach($config['filters'] as $filterConfig) {
312
-				$this->createAppenderFilter($appender, $filterConfig);
313
-			}
314
-		}
309
+        // Parse filters
310
+        if (isset($config['filters']) && is_array($config['filters'])) {
311
+            foreach($config['filters'] as $filterConfig) {
312
+                $this->createAppenderFilter($appender, $filterConfig);
313
+            }
314
+        }
315 315
 		
316
-		// Set options if any
317
-		if (isset($config['params'])) {
318
-			$this->setOptions($appender, $config['params']);
319
-		}
316
+        // Set options if any
317
+        if (isset($config['params'])) {
318
+            $this->setOptions($appender, $config['params']);
319
+        }
320 320
 
321
-		// Activate and save for later linking to loggers
322
-		$appender->activateOptions();
323
-		$this->appenders[$name] = $appender;
324
-	}
321
+        // Activate and save for later linking to loggers
322
+        $appender->activateOptions();
323
+        $this->appenders[$name] = $appender;
324
+    }
325 325
 	
326
-	/**
327
-	 * Parses layout config, creates the layout and links it to the appender.
328
-	 * @param Payone_Log4php_LoggerAppender $appender
329
-	 * @param array $config Layout configuration.
330
-	 */
331
-	private function createAppenderLayout(Payone_Log4php_LoggerAppender $appender, $config) {
332
-		$name = $appender->getName();
333
-		$class = $config['class'];
334
-		if (empty($class)) {
335
-			$this->warn("Layout class not specified for appender [$name]. Reverting to default layout.");
336
-			return;
337
-		}
338
-		if (!class_exists($class)) {
339
-			$this->warn("Nonexistant layout class [$class] specified for appender [$name]. Reverting to default layout.");
340
-			return;
341
-		}
326
+    /**
327
+     * Parses layout config, creates the layout and links it to the appender.
328
+     * @param Payone_Log4php_LoggerAppender $appender
329
+     * @param array $config Layout configuration.
330
+     */
331
+    private function createAppenderLayout(Payone_Log4php_LoggerAppender $appender, $config) {
332
+        $name = $appender->getName();
333
+        $class = $config['class'];
334
+        if (empty($class)) {
335
+            $this->warn("Layout class not specified for appender [$name]. Reverting to default layout.");
336
+            return;
337
+        }
338
+        if (!class_exists($class)) {
339
+            $this->warn("Nonexistant layout class [$class] specified for appender [$name]. Reverting to default layout.");
340
+            return;
341
+        }
342 342
 		
343
-		$layout = new $class();
344
-		if (!($layout instanceof Payone_Log4php_LoggerLayout)) {
345
-			$this->warn("Invalid layout class [$class] sepcified for appender [$name]. Reverting to default layout.");
346
-			return;
347
-		}
343
+        $layout = new $class();
344
+        if (!($layout instanceof Payone_Log4php_LoggerLayout)) {
345
+            $this->warn("Invalid layout class [$class] sepcified for appender [$name]. Reverting to default layout.");
346
+            return;
347
+        }
348 348
 		
349
-		if (isset($config['params'])) {
350
-			$this->setOptions($layout, $config['params']);
351
-		}
349
+        if (isset($config['params'])) {
350
+            $this->setOptions($layout, $config['params']);
351
+        }
352 352
 		
353
-		$layout->activateOptions();
354
-		$appender->setLayout($layout);
355
-	}
353
+        $layout->activateOptions();
354
+        $appender->setLayout($layout);
355
+    }
356 356
 	
357
-	/**
358
-	 * Parses filter config, creates the filter and adds it to the appender's 
359
-	 * filter chain.
360
-	 * @param Payone_Log4php_LoggerAppender $appender
361
-	 * @param array $config Filter configuration.
362
-	 */
363
-	private function createAppenderFilter(Payone_Log4php_LoggerAppender $appender, $config) {
364
-		$name = $appender->getName();
365
-		$class = $config['class'];
366
-		if (!class_exists($class)) {
367
-			$this->warn("Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.");
368
-			return;
369
-		}
357
+    /**
358
+     * Parses filter config, creates the filter and adds it to the appender's 
359
+     * filter chain.
360
+     * @param Payone_Log4php_LoggerAppender $appender
361
+     * @param array $config Filter configuration.
362
+     */
363
+    private function createAppenderFilter(Payone_Log4php_LoggerAppender $appender, $config) {
364
+        $name = $appender->getName();
365
+        $class = $config['class'];
366
+        if (!class_exists($class)) {
367
+            $this->warn("Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.");
368
+            return;
369
+        }
370 370
 	
371
-		$filter = new $class();
372
-		if (!($filter instanceof Payone_Log4php_LoggerFilter)) {
373
-			$this->warn("Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.");
374
-			return;
375
-		}
371
+        $filter = new $class();
372
+        if (!($filter instanceof Payone_Log4php_LoggerFilter)) {
373
+            $this->warn("Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.");
374
+            return;
375
+        }
376 376
 	
377
-		if (isset($config['params'])) {
378
-			$this->setOptions($filter, $config['params']);
379
-		}
377
+        if (isset($config['params'])) {
378
+            $this->setOptions($filter, $config['params']);
379
+        }
380 380
 	
381
-		$filter->activateOptions();
382
-		$appender->addFilter($filter);
383
-	}
381
+        $filter->activateOptions();
382
+        $appender->addFilter($filter);
383
+    }
384 384
 	
385
-	/** 
386
-	 * Configures the root logger
387
-	 * @see configureLogger() 
388
-	 */
389
-	private function configureRootLogger(Payone_Log4php_LoggerHierarchy $hierarchy, $config) {
390
-		$logger = $hierarchy->getRootLogger();
391
-		$this->configureLogger($logger, $config);
392
-	}
385
+    /** 
386
+     * Configures the root logger
387
+     * @see configureLogger() 
388
+     */
389
+    private function configureRootLogger(Payone_Log4php_LoggerHierarchy $hierarchy, $config) {
390
+        $logger = $hierarchy->getRootLogger();
391
+        $this->configureLogger($logger, $config);
392
+    }
393 393
 
394
-	/**
395
-	 * Configures a logger which is not root.
396
-	 * @see configureLogger()
397
-	 */
398
-	private function configureOtherLogger(Payone_Log4php_LoggerHierarchy $hierarchy, $name, $config) {
399
-		// Get logger from hierarchy (this creates it if it doesn't already exist)
400
-		$logger = $hierarchy->getLogger($name);
401
-		$this->configureLogger($logger, $config);
402
-	}
394
+    /**
395
+     * Configures a logger which is not root.
396
+     * @see configureLogger()
397
+     */
398
+    private function configureOtherLogger(Payone_Log4php_LoggerHierarchy $hierarchy, $name, $config) {
399
+        // Get logger from hierarchy (this creates it if it doesn't already exist)
400
+        $logger = $hierarchy->getLogger($name);
401
+        $this->configureLogger($logger, $config);
402
+    }
403 403
 	
404
-	/**
405
-	 * Configures a logger. 
406
-	 * 
407
-	 * @param Logger $logger The logger to configure
408
-	 * @param array $config Logger configuration options.
409
-	 */
410
-	private function configureLogger(Payone_Log4php_Logger $logger, $config) {
411
-		$loggerName = $logger->getName();
404
+    /**
405
+     * Configures a logger. 
406
+     * 
407
+     * @param Logger $logger The logger to configure
408
+     * @param array $config Logger configuration options.
409
+     */
410
+    private function configureLogger(Payone_Log4php_Logger $logger, $config) {
411
+        $loggerName = $logger->getName();
412 412
 		
413
-		// Set logger level
414
-		if (isset($config['level'])) {
415
-			$level = Payone_Log4php_LoggerLevel::toLevel($config['level']);
416
-			if (isset($level)) {
417
-				$logger->setLevel($level);
418
-			} else {
419
-				$default = $logger->getLevel();
420
-				$this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
421
-			}
422
-		}
413
+        // Set logger level
414
+        if (isset($config['level'])) {
415
+            $level = Payone_Log4php_LoggerLevel::toLevel($config['level']);
416
+            if (isset($level)) {
417
+                $logger->setLevel($level);
418
+            } else {
419
+                $default = $logger->getLevel();
420
+                $this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
421
+            }
422
+        }
423 423
 		
424
-		// Link appenders to logger
425
-		if (isset($config['appenders'])) {
426
-			foreach($config['appenders'] as $appenderName) {
427
-				if (isset($this->appenders[$appenderName])) {
428
-					$logger->addAppender($this->appenders[$appenderName]);
429
-				} else {
430
-					$this->warn("Nonexistnant appender [$appenderName] linked to logger [$loggerName].");
431
-				}
432
-			}
433
-		}
424
+        // Link appenders to logger
425
+        if (isset($config['appenders'])) {
426
+            foreach($config['appenders'] as $appenderName) {
427
+                if (isset($this->appenders[$appenderName])) {
428
+                    $logger->addAppender($this->appenders[$appenderName]);
429
+                } else {
430
+                    $this->warn("Nonexistnant appender [$appenderName] linked to logger [$loggerName].");
431
+                }
432
+            }
433
+        }
434 434
 		
435
-		// Set logger additivity
436
-		if (isset($config['additivity'])) {
437
-			$additivity = Payone_Log4php_LoggerOptionConverter::toBoolean($config['additivity'], null);
438
-			if (is_bool($additivity)) {
439
-				$logger->setAdditivity($additivity);
440
-			} else {
441
-				$this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
442
-			}
443
-		}
444
-	}
435
+        // Set logger additivity
436
+        if (isset($config['additivity'])) {
437
+            $additivity = Payone_Log4php_LoggerOptionConverter::toBoolean($config['additivity'], null);
438
+            if (is_bool($additivity)) {
439
+                $logger->setAdditivity($additivity);
440
+            } else {
441
+                $this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
442
+            }
443
+        }
444
+    }
445 445
 
446
-	/**
447
-	 * Helper method which applies given options to an object which has setters
448
-	 * for these options (such as appenders, layouts, etc.).
449
-	 * 
450
-	 * For example, if options are:
451
-	 * <code>
452
-	 * array(
453
-	 * 	'file' => '/tmp/myfile.log',
454
-	 * 	'append' => true
455
-	 * )
456
-	 * </code>
457
-	 * 
458
-	 * This method will call:
459
-	 * <code>
460
-	 * $object->setFile('/tmp/myfile.log')
461
-	 * $object->setAppend(true)
462
-	 * </code>
463
-	 * 
464
-	 * If required setters do not exist, it will produce a warning. 
465
-	 * 
466
-	 * @param mixed $object The object to configure.
467
-	 * @param unknown_type $options
468
-	 */
469
-	private function setOptions($object, $options) {
470
-		foreach($options as $name => $value) {
471
-			$setter = "set$name";
472
-			if (method_exists($object, $setter)) {
473
-				$object->$setter($value);
474
-			} else {
475
-				$class = get_class($object);
476
-				$this->warn("Nonexistant option [$name] specified on [$class]. Skipping.");
477
-			}
478
-		}
479
-	}
446
+    /**
447
+     * Helper method which applies given options to an object which has setters
448
+     * for these options (such as appenders, layouts, etc.).
449
+     * 
450
+     * For example, if options are:
451
+     * <code>
452
+     * array(
453
+     * 	'file' => '/tmp/myfile.log',
454
+     * 	'append' => true
455
+     * )
456
+     * </code>
457
+     * 
458
+     * This method will call:
459
+     * <code>
460
+     * $object->setFile('/tmp/myfile.log')
461
+     * $object->setAppend(true)
462
+     * </code>
463
+     * 
464
+     * If required setters do not exist, it will produce a warning. 
465
+     * 
466
+     * @param mixed $object The object to configure.
467
+     * @param unknown_type $options
468
+     */
469
+    private function setOptions($object, $options) {
470
+        foreach($options as $name => $value) {
471
+            $setter = "set$name";
472
+            if (method_exists($object, $setter)) {
473
+                $object->$setter($value);
474
+            } else {
475
+                $class = get_class($object);
476
+                $this->warn("Nonexistant option [$name] specified on [$class]. Skipping.");
477
+            }
478
+        }
479
+    }
480 480
 	
481
-	/** Helper method to simplify error reporting. */
482
-	private function warn($message) {
483
-		trigger_error("log4php: $message", E_USER_WARNING);
484
-	}
481
+    /** Helper method to simplify error reporting. */
482
+    private function warn($message) {
483
+        trigger_error("log4php: $message", E_USER_WARNING);
484
+    }
485 485
 }
486 486
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		$info = pathinfo($url);
168 168
 		$ext = strtolower($info['extension']);
169 169
 		
170
-		switch($ext) {
170
+		switch ($ext) {
171 171
 			case 'xml':
172 172
 				return self::FORMAT_XML;
173 173
 			
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		
202 202
 		// Configure appenders and add them to the appender pool
203 203
 		if (isset($config['appenders']) && is_array($config['appenders'])) {
204
-			foreach($config['appenders'] as $name => $appenderConfig) {
204
+			foreach ($config['appenders'] as $name => $appenderConfig) {
205 205
 				$this->configureAppender($name, $appenderConfig);
206 206
 			}
207 207
 		}
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
 		
214 214
 		// Configure loggers
215 215
 		if (isset($config['loggers']) && is_array($config['loggers'])) {
216
-			foreach($config['loggers'] as $loggerName => $loggerConfig) {
216
+			foreach ($config['loggers'] as $loggerName => $loggerConfig) {
217 217
 				$this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
218 218
 			}
219 219
 		}
220 220
 
221 221
 		// Configure renderers
222 222
 		if (isset($config['renderers']) && is_array($config['renderers'])) {
223
-			foreach($config['renderers'] as $rendererConfig) {
223
+			foreach ($config['renderers'] as $rendererConfig) {
224 224
 				$this->configureRenderer($hierarchy, $rendererConfig);
225 225
 			}
226 226
 		}
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 		
309 309
 		// Parse filters
310 310
 		if (isset($config['filters']) && is_array($config['filters'])) {
311
-			foreach($config['filters'] as $filterConfig) {
311
+			foreach ($config['filters'] as $filterConfig) {
312 312
 				$this->createAppenderFilter($appender, $filterConfig);
313 313
 			}
314 314
 		}
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 		
424 424
 		// Link appenders to logger
425 425
 		if (isset($config['appenders'])) {
426
-			foreach($config['appenders'] as $appenderName) {
426
+			foreach ($config['appenders'] as $appenderName) {
427 427
 				if (isset($this->appenders[$appenderName])) {
428 428
 					$logger->addAppender($this->appenders[$appenderName]);
429 429
 				} else {
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @param unknown_type $options
468 468
 	 */
469 469
 	private function setOptions($object, $options) {
470
-		foreach($options as $name => $value) {
470
+		foreach ($options as $name => $value) {
471 471
 			$setter = "set$name";
472 472
 			if (method_exists($object, $setter)) {
473 473
 				$object->$setter($value);
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerFilterLevelMatch.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,6 @@
 block discarded – undo
67 67
 	}
68 68
 	
69 69
 	/**
70
-	 * @param string $l the level to match
71 70
 	 */
72 71
 	public function setLevelToMatch($level) {
73 72
 		$this->setLevel('levelToMatch', $level);
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -47,54 +47,54 @@
 block discarded – undo
47 47
  */
48 48
 class Payone_Log4php_LoggerFilterLevelMatch extends Payone_Log4php_LoggerFilter {
49 49
   
50
-	/** 
51
-	 * Indicates if this event should be accepted or denied on match
52
-	 * @var boolean
53
-	 */
54
-	protected $acceptOnMatch = true;
50
+    /** 
51
+     * Indicates if this event should be accepted or denied on match
52
+     * @var boolean
53
+     */
54
+    protected $acceptOnMatch = true;
55 55
 
56
-	/**
57
-	 * The level, when to match
58
-	 * @var Payone_Log4php_LoggerLevel
59
-	 */
60
-	protected $levelToMatch;
56
+    /**
57
+     * The level, when to match
58
+     * @var Payone_Log4php_LoggerLevel
59
+     */
60
+    protected $levelToMatch;
61 61
   
62
-	/**
63
-	 * @param boolean $acceptOnMatch
64
-	 */
65
-	public function setAcceptOnMatch($acceptOnMatch) {
66
-		$this->setBoolean('acceptOnMatch', $acceptOnMatch);
67
-	}
62
+    /**
63
+     * @param boolean $acceptOnMatch
64
+     */
65
+    public function setAcceptOnMatch($acceptOnMatch) {
66
+        $this->setBoolean('acceptOnMatch', $acceptOnMatch);
67
+    }
68 68
 	
69
-	/**
70
-	 * @param string $l the level to match
71
-	 */
72
-	public function setLevelToMatch($level) {
73
-		$this->setLevel('levelToMatch', $level);
74
-	}
69
+    /**
70
+     * @param string $l the level to match
71
+     */
72
+    public function setLevelToMatch($level) {
73
+        $this->setLevel('levelToMatch', $level);
74
+    }
75 75
 
76
-	/**
77
-	 * Return the decision of this filter.
78
-	 * 
79
-	 * Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b>
80
-	 * option is not set or if there is not match.	Otherwise, if there is a
81
-	 * match, then the returned decision is {@link LoggerFilter::ACCEPT} if the
82
-	 * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
83
-	 * returned decision is {@link LoggerFilter::DENY} if the
84
-	 * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
85
-	 *
86
-	 * @param Payone_Log4php_LoggerLoggingEvent $event
87
-	 * @return integer
88
-	 */
89
-	public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
90
-		if($this->levelToMatch === null) {
91
-			return Payone_Log4php_LoggerFilter::NEUTRAL;
92
-		}
76
+    /**
77
+     * Return the decision of this filter.
78
+     * 
79
+     * Returns {@link LoggerFilter::NEUTRAL} if the <b><var>LevelToMatch</var></b>
80
+     * option is not set or if there is not match.	Otherwise, if there is a
81
+     * match, then the returned decision is {@link LoggerFilter::ACCEPT} if the
82
+     * <b><var>AcceptOnMatch</var></b> property is set to <i>true</i>. The
83
+     * returned decision is {@link LoggerFilter::DENY} if the
84
+     * <b><var>AcceptOnMatch</var></b> property is set to <i>false</i>.
85
+     *
86
+     * @param Payone_Log4php_LoggerLoggingEvent $event
87
+     * @return integer
88
+     */
89
+    public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
90
+        if($this->levelToMatch === null) {
91
+            return Payone_Log4php_LoggerFilter::NEUTRAL;
92
+        }
93 93
 		
94
-		if($this->levelToMatch->equals($event->getLevel())) {	
95
-			return $this->acceptOnMatch ? Payone_Log4php_LoggerFilter::ACCEPT : Payone_Log4php_LoggerFilter::DENY;
96
-		} else {
97
-			return Payone_Log4php_LoggerFilter::NEUTRAL;
98
-		}
99
-	}
94
+        if($this->levelToMatch->equals($event->getLevel())) {	
95
+            return $this->acceptOnMatch ? Payone_Log4php_LoggerFilter::ACCEPT : Payone_Log4php_LoggerFilter::DENY;
96
+        } else {
97
+            return Payone_Log4php_LoggerFilter::NEUTRAL;
98
+        }
99
+    }
100 100
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,11 +87,11 @@
 block discarded – undo
87 87
 	 * @return integer
88 88
 	 */
89 89
 	public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
90
-		if($this->levelToMatch === null) {
90
+		if ($this->levelToMatch === null) {
91 91
 			return Payone_Log4php_LoggerFilter::NEUTRAL;
92 92
 		}
93 93
 		
94
-		if($this->levelToMatch->equals($event->getLevel())) {	
94
+		if ($this->levelToMatch->equals($event->getLevel())) {	
95 95
 			return $this->acceptOnMatch ? Payone_Log4php_LoggerFilter::ACCEPT : Payone_Log4php_LoggerFilter::DENY;
96 96
 		} else {
97 97
 			return Payone_Log4php_LoggerFilter::NEUTRAL;
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerFilterLevelRange.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -87,14 +87,12 @@
 block discarded – undo
87 87
 	}
88 88
 	
89 89
 	/**
90
-	 * @param string $l the level min to match
91 90
 	 */
92 91
 	public function setLevelMin($level) {
93 92
 		$this->setLevel('levelMin', $level);
94 93
 	}
95 94
 
96 95
 	/**
97
-	 * @param string $l the level max to match
98 96
 	 */
99 97
 	public function setLevelMax($level) {
100 98
 		$this->setLevel('levelMax', $level);
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -64,75 +64,75 @@
 block discarded – undo
64 64
  */
65 65
 class Payone_Log4php_LoggerFilterLevelRange extends Payone_Log4php_LoggerFilter {
66 66
 
67
-	/**
68
-	 * @var boolean
69
-	 */
70
-	protected $acceptOnMatch = true;
67
+    /**
68
+     * @var boolean
69
+     */
70
+    protected $acceptOnMatch = true;
71 71
 
72
-	/**
73
-	 * @var Payone_Log4php_LoggerLevel
74
-	 */
75
-	protected $levelMin;
72
+    /**
73
+     * @var Payone_Log4php_LoggerLevel
74
+     */
75
+    protected $levelMin;
76 76
   
77
-	/**
78
-	 * @var Payone_Log4php_LoggerLevel
79
-	 */
80
-	protected $levelMax;
77
+    /**
78
+     * @var Payone_Log4php_LoggerLevel
79
+     */
80
+    protected $levelMax;
81 81
 
82
-	/**
83
-	 * @param boolean $acceptOnMatch
84
-	 */
85
-	public function setAcceptOnMatch($acceptOnMatch) {
86
-		$this->setBoolean('acceptOnMatch', $acceptOnMatch); 
87
-	}
82
+    /**
83
+     * @param boolean $acceptOnMatch
84
+     */
85
+    public function setAcceptOnMatch($acceptOnMatch) {
86
+        $this->setBoolean('acceptOnMatch', $acceptOnMatch); 
87
+    }
88 88
 	
89
-	/**
90
-	 * @param string $l the level min to match
91
-	 */
92
-	public function setLevelMin($level) {
93
-		$this->setLevel('levelMin', $level);
94
-	}
89
+    /**
90
+     * @param string $l the level min to match
91
+     */
92
+    public function setLevelMin($level) {
93
+        $this->setLevel('levelMin', $level);
94
+    }
95 95
 
96
-	/**
97
-	 * @param string $l the level max to match
98
-	 */
99
-	public function setLevelMax($level) {
100
-		$this->setLevel('levelMax', $level);
101
-	}
96
+    /**
97
+     * @param string $l the level max to match
98
+     */
99
+    public function setLevelMax($level) {
100
+        $this->setLevel('levelMax', $level);
101
+    }
102 102
 
103
-	/**
104
-	 * Return the decision of this filter.
105
-	 *
106
-	 * @param Payone_Log4php_LoggerLoggingEvent $event
107
-	 * @return integer
108
-	 */
109
-	public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
110
-		$level = $event->getLevel();
103
+    /**
104
+     * Return the decision of this filter.
105
+     *
106
+     * @param Payone_Log4php_LoggerLoggingEvent $event
107
+     * @return integer
108
+     */
109
+    public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
110
+        $level = $event->getLevel();
111 111
 		
112
-		if($this->levelMin !== null) {
113
-			if($level->isGreaterOrEqual($this->levelMin) == false) {
114
-				// level of event is less than minimum
115
-				return Payone_Log4php_LoggerFilter::DENY;
116
-			}
117
-		}
112
+        if($this->levelMin !== null) {
113
+            if($level->isGreaterOrEqual($this->levelMin) == false) {
114
+                // level of event is less than minimum
115
+                return Payone_Log4php_LoggerFilter::DENY;
116
+            }
117
+        }
118 118
 
119
-		if($this->levelMax !== null) {
120
-			if($level->toInt() > $this->levelMax->toInt()) {
121
-				// level of event is greater than maximum
122
-				// Alas, there is no Level.isGreater method. and using
123
-				// a combo of isGreaterOrEqual && !Equal seems worse than
124
-				// checking the int values of the level objects..
125
-				return Payone_Log4php_LoggerFilter::DENY;
126
-			}
127
-		}
119
+        if($this->levelMax !== null) {
120
+            if($level->toInt() > $this->levelMax->toInt()) {
121
+                // level of event is greater than maximum
122
+                // Alas, there is no Level.isGreater method. and using
123
+                // a combo of isGreaterOrEqual && !Equal seems worse than
124
+                // checking the int values of the level objects..
125
+                return Payone_Log4php_LoggerFilter::DENY;
126
+            }
127
+        }
128 128
 
129
-		if($this->acceptOnMatch) {
130
-			// this filter set up to bypass later filters and always return
131
-			// accept if level in range
132
-			return Payone_Log4php_LoggerFilter::ACCEPT;
133
-		} else {
134
-			// event is ok for this filter; allow later filters to have a look..
135
-			return Payone_Log4php_LoggerFilter::NEUTRAL;
136
-		}
137
-	}
129
+        if($this->acceptOnMatch) {
130
+            // this filter set up to bypass later filters and always return
131
+            // accept if level in range
132
+            return Payone_Log4php_LoggerFilter::ACCEPT;
133
+        } else {
134
+            // event is ok for this filter; allow later filters to have a look..
135
+            return Payone_Log4php_LoggerFilter::NEUTRAL;
136
+        }
137
+    }
138 138
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 	public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
110 110
 		$level = $event->getLevel();
111 111
 		
112
-		if($this->levelMin !== null) {
113
-			if($level->isGreaterOrEqual($this->levelMin) == false) {
112
+		if ($this->levelMin !== null) {
113
+			if ($level->isGreaterOrEqual($this->levelMin) == false) {
114 114
 				// level of event is less than minimum
115 115
 				return Payone_Log4php_LoggerFilter::DENY;
116 116
 			}
117 117
 		}
118 118
 
119
-		if($this->levelMax !== null) {
120
-			if($level->toInt() > $this->levelMax->toInt()) {
119
+		if ($this->levelMax !== null) {
120
+			if ($level->toInt() > $this->levelMax->toInt()) {
121 121
 				// level of event is greater than maximum
122 122
 				// Alas, there is no Level.isGreater method. and using
123 123
 				// a combo of isGreaterOrEqual && !Equal seems worse than
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			}
127 127
 		}
128 128
 
129
-		if($this->acceptOnMatch) {
129
+		if ($this->acceptOnMatch) {
130 130
 			// this filter set up to bypass later filters and always return
131 131
 			// accept if level in range
132 132
 			return Payone_Log4php_LoggerFilter::ACCEPT;
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerFilterStringMatch.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,6 @@
 block discarded – undo
65 65
 	}
66 66
 	
67 67
 	/**
68
-	 * @param string $s the string to match
69 68
 	 */
70 69
 	public function setStringToMatch($string) {
71 70
 		$this->setString('stringToMatch', $string);
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -47,43 +47,43 @@
 block discarded – undo
47 47
  */
48 48
 class Payone_Log4php_LoggerFilterStringMatch extends Payone_Log4php_LoggerFilter {
49 49
 
50
-	/**
51
-	 * @var boolean
52
-	 */
53
-	protected $acceptOnMatch = true;
50
+    /**
51
+     * @var boolean
52
+     */
53
+    protected $acceptOnMatch = true;
54 54
 
55
-	/**
56
-	 * @var string
57
-	 */
58
-	protected $stringToMatch;
55
+    /**
56
+     * @var string
57
+     */
58
+    protected $stringToMatch;
59 59
 
60
-	/**
61
-	 * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
62
-	 */
63
-	public function setAcceptOnMatch($acceptOnMatch) {
64
-		$this->setBoolean('acceptOnMatch', $acceptOnMatch);
65
-	}
60
+    /**
61
+     * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false')
62
+     */
63
+    public function setAcceptOnMatch($acceptOnMatch) {
64
+        $this->setBoolean('acceptOnMatch', $acceptOnMatch);
65
+    }
66 66
 	
67
-	/**
68
-	 * @param string $s the string to match
69
-	 */
70
-	public function setStringToMatch($string) {
71
-		$this->setString('stringToMatch', $string);
72
-	}
67
+    /**
68
+     * @param string $s the string to match
69
+     */
70
+    public function setStringToMatch($string) {
71
+        $this->setString('stringToMatch', $string);
72
+    }
73 73
 
74
-	/**
75
-	 * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
76
-	 */
77
-	public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
78
-		$msg = $event->getRenderedMessage();
74
+    /**
75
+     * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match.
76
+     */
77
+    public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
78
+        $msg = $event->getRenderedMessage();
79 79
 		
80
-		if($msg === null or $this->stringToMatch === null) {
81
-			return Payone_Log4php_LoggerFilter::NEUTRAL;
82
-		}
80
+        if($msg === null or $this->stringToMatch === null) {
81
+            return Payone_Log4php_LoggerFilter::NEUTRAL;
82
+        }
83 83
 		
84
-		if(strpos($msg, $this->stringToMatch) !== false ) {
85
-			return ($this->acceptOnMatch) ? Payone_Log4php_LoggerFilter::ACCEPT : Payone_Log4php_LoggerFilter::DENY;
86
-		}
87
-		return Payone_Log4php_LoggerFilter::NEUTRAL;
88
-	}
84
+        if(strpos($msg, $this->stringToMatch) !== false ) {
85
+            return ($this->acceptOnMatch) ? Payone_Log4php_LoggerFilter::ACCEPT : Payone_Log4php_LoggerFilter::DENY;
86
+        }
87
+        return Payone_Log4php_LoggerFilter::NEUTRAL;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,11 +77,11 @@
 block discarded – undo
77 77
 	public function decide(Payone_Log4php_LoggerLoggingEvent $event) {
78 78
 		$msg = $event->getRenderedMessage();
79 79
 		
80
-		if($msg === null or $this->stringToMatch === null) {
80
+		if ($msg === null or $this->stringToMatch === null) {
81 81
 			return Payone_Log4php_LoggerFilter::NEUTRAL;
82 82
 		}
83 83
 		
84
-		if(strpos($msg, $this->stringToMatch) !== false ) {
84
+		if (strpos($msg, $this->stringToMatch) !== false) {
85 85
 			return ($this->acceptOnMatch) ? Payone_Log4php_LoggerFilter::ACCEPT : Payone_Log4php_LoggerFilter::DENY;
86 86
 		}
87 87
 		return Payone_Log4php_LoggerFilter::NEUTRAL;
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerHierarchy.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -213,7 +213,6 @@
 block discarded – undo
213 213
 	
214 214
 	/**
215 215
 	 * Sets the main threshold level.
216
-	 * @param Payone_Log4php_LoggerLevel $l
217 216
 	 */
218 217
 	public function setThreshold(Payone_Log4php_LoggerLevel $threshold) {
219 218
 		$this->threshold = $threshold;
Please login to merge, or discard this patch.
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -49,192 +49,192 @@
 block discarded – undo
49 49
  */
50 50
 class Payone_Log4php_LoggerHierarchy {
51 51
 	
52
-	/** Array holding all Logger instances. */
53
-	protected $loggers = array();
52
+    /** Array holding all Logger instances. */
53
+    protected $loggers = array();
54 54
 	
55
-	/** 
56
-	 * The root logger.
57
-	 * @var RootLogger 
58
-	 */
59
-	protected $root = null;
55
+    /** 
56
+     * The root logger.
57
+     * @var RootLogger 
58
+     */
59
+    protected $root = null;
60 60
 	
61
-	/** 
62
-	 * The logger renderer map.
63
-	 * @var Payone_Log4php_LoggerRendererMap
64
-	 */
65
-	protected $rendererMap;
61
+    /** 
62
+     * The logger renderer map.
63
+     * @var Payone_Log4php_LoggerRendererMap
64
+     */
65
+    protected $rendererMap;
66 66
 
67
-	/** 
68
-	 * Main level threshold. Events with lower level will not be logged by any 
69
-	 * logger, regardless of it's configuration.
70
-	 * @var Payone_Log4php_LoggerLevel
71
-	 */
72
-	protected $threshold;
67
+    /** 
68
+     * Main level threshold. Events with lower level will not be logged by any 
69
+     * logger, regardless of it's configuration.
70
+     * @var Payone_Log4php_LoggerLevel
71
+     */
72
+    protected $threshold;
73 73
 	
74
-	/**
75
-	 * Creates a new logger hierarchy.
76
-	 * @param Payone_Log4php_LoggerRoot $root The root logger.
77
-	 */
78
-	public function __construct(Payone_Log4php_LoggerRoot $root) {
79
-		$this->root = $root;
80
-		$this->setThreshold(Payone_Log4php_LoggerLevel::getLevelAll());
81
-		$this->rendererMap = new Payone_Log4php_LoggerRendererMap();
82
-	}
74
+    /**
75
+     * Creates a new logger hierarchy.
76
+     * @param Payone_Log4php_LoggerRoot $root The root logger.
77
+     */
78
+    public function __construct(Payone_Log4php_LoggerRoot $root) {
79
+        $this->root = $root;
80
+        $this->setThreshold(Payone_Log4php_LoggerLevel::getLevelAll());
81
+        $this->rendererMap = new Payone_Log4php_LoggerRendererMap();
82
+    }
83 83
 	 
84
-	/**
85
-	 * Clears all loggers.
86
-	 */
87
-	public function clear() {
88
-		$this->loggers = array();
89
-	}
84
+    /**
85
+     * Clears all loggers.
86
+     */
87
+    public function clear() {
88
+        $this->loggers = array();
89
+    }
90 90
 	
91
-	/**
92
-	 * Check if the named logger exists in the hierarchy.
93
-	 * @param string $name
94
-	 * @return boolean
95
-	 */
96
-	public function exists($name) {
97
-		return isset($this->loggers[$name]);
98
-	}
91
+    /**
92
+     * Check if the named logger exists in the hierarchy.
93
+     * @param string $name
94
+     * @return boolean
95
+     */
96
+    public function exists($name) {
97
+        return isset($this->loggers[$name]);
98
+    }
99 99
 
100
-	/**
101
-	 * Returns all the currently defined loggers in this hierarchy as an array.
102
-	 * @return array
103
-	 */	 
104
-	public function getCurrentLoggers() {
105
-		return array_values($this->loggers);
106
-	}
100
+    /**
101
+     * Returns all the currently defined loggers in this hierarchy as an array.
102
+     * @return array
103
+     */	 
104
+    public function getCurrentLoggers() {
105
+        return array_values($this->loggers);
106
+    }
107 107
 	
108
-	/**
109
-	 * Returns a named logger instance logger. If it doesn't exist, one is created.
110
-	 * 
111
-	 * @param string $name Logger name
112
-	 * @return Logger Logger instance.
113
-	 */
114
-	public function getLogger($name) {
115
-		if(!isset($this->loggers[$name])) {
116
-			$logger = new Payone_Log4php_Logger($name);
108
+    /**
109
+     * Returns a named logger instance logger. If it doesn't exist, one is created.
110
+     * 
111
+     * @param string $name Logger name
112
+     * @return Logger Logger instance.
113
+     */
114
+    public function getLogger($name) {
115
+        if(!isset($this->loggers[$name])) {
116
+            $logger = new Payone_Log4php_Logger($name);
117 117
 
118
-			$nodes = explode('.', $name);
119
-			$firstNode = array_shift($nodes);
118
+            $nodes = explode('.', $name);
119
+            $firstNode = array_shift($nodes);
120 120
 			
121
-			// if name is not a first node but another first node is their
122
-			if($firstNode != $name and isset($this->loggers[$firstNode])) {
123
-				$logger->setParent($this->loggers[$firstNode]);
124
-			} else {
125
-				// if there is no father, set root logger as father
126
-				$logger->setParent($this->root);
127
-			} 
121
+            // if name is not a first node but another first node is their
122
+            if($firstNode != $name and isset($this->loggers[$firstNode])) {
123
+                $logger->setParent($this->loggers[$firstNode]);
124
+            } else {
125
+                // if there is no father, set root logger as father
126
+                $logger->setParent($this->root);
127
+            } 
128 128
 		
129
-			// if there are more nodes than one
130
-			if(count($nodes) > 0) {
131
-				// find parent node
132
-				foreach($nodes as $node) {
133
-					$parentNode = "$firstNode.$node";
134
-					if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
135
-						$logger->setParent($this->loggers[$parentNode]);
136
-					}
137
-					$firstNode .= ".$node";
138
-				}
139
-			}
129
+            // if there are more nodes than one
130
+            if(count($nodes) > 0) {
131
+                // find parent node
132
+                foreach($nodes as $node) {
133
+                    $parentNode = "$firstNode.$node";
134
+                    if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
135
+                        $logger->setParent($this->loggers[$parentNode]);
136
+                    }
137
+                    $firstNode .= ".$node";
138
+                }
139
+            }
140 140
 			
141
-			$this->loggers[$name] = $logger;
142
-		}		
141
+            $this->loggers[$name] = $logger;
142
+        }		
143 143
 		
144
-		return $this->loggers[$name];
145
-	} 
144
+        return $this->loggers[$name];
145
+    } 
146 146
 	
147
-	/**
148
-	 * Returns the logger renderer map.
149
-	 * @return Payone_Log4php_LoggerRendererMap
150
-	 */
151
-	public function getRendererMap() {
152
-		return $this->rendererMap;
153
-	}
147
+    /**
148
+     * Returns the logger renderer map.
149
+     * @return Payone_Log4php_LoggerRendererMap
150
+     */
151
+    public function getRendererMap() {
152
+        return $this->rendererMap;
153
+    }
154 154
 	
155
-	/**
156
-	 * Returns the root logger.
157
-	 * @return Payone_Log4php_LoggerRoot
158
-	 */ 
159
-	public function getRootLogger() {
160
-		if(!isset($this->root) or $this->root == null) {
161
-			$this->root = new Payone_Log4php_LoggerRoot();
162
-		}
163
-		return $this->root;
164
-	}
155
+    /**
156
+     * Returns the root logger.
157
+     * @return Payone_Log4php_LoggerRoot
158
+     */ 
159
+    public function getRootLogger() {
160
+        if(!isset($this->root) or $this->root == null) {
161
+            $this->root = new Payone_Log4php_LoggerRoot();
162
+        }
163
+        return $this->root;
164
+    }
165 165
 	 
166
-	/**
167
-	 * Returns the main threshold level.
168
-	 * @return Payone_Log4php_LoggerLevel
169
-	 */
170
-	public function getThreshold() {
171
-		return $this->threshold;
172
-	} 
166
+    /**
167
+     * Returns the main threshold level.
168
+     * @return Payone_Log4php_LoggerLevel
169
+     */
170
+    public function getThreshold() {
171
+        return $this->threshold;
172
+    } 
173 173
 
174
-	/**
175
-	 * Returns true if the hierarchy is disabled for given log level and false
176
-	 * otherwise.
177
-	 * @return boolean
178
-	 */
179
-	public function isDisabled(Payone_Log4php_LoggerLevel $level) {
180
-		return ($this->threshold->toInt() > $level->toInt());
181
-	}
174
+    /**
175
+     * Returns true if the hierarchy is disabled for given log level and false
176
+     * otherwise.
177
+     * @return boolean
178
+     */
179
+    public function isDisabled(Payone_Log4php_LoggerLevel $level) {
180
+        return ($this->threshold->toInt() > $level->toInt());
181
+    }
182 182
 	
183
-	/**
184
-	 * Reset all values contained in this hierarchy instance to their
185
-	 * default. 
186
-	 *
187
-	 * This removes all appenders from all loggers, sets
188
-	 * the level of all non-root loggers to <i>null</i>,
189
-	 * sets their additivity flag to <i>true</i> and sets the level
190
-	 * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
191
-	 * 
192
-	 * <p>Existing loggers are not removed. They are just reset.
193
-	 *
194
-	 * <p>This method should be used sparingly and with care as it will
195
-	 * block all logging until it is completed.</p>
196
-	 */
197
-	public function resetConfiguration() {
198
-		$root = $this->getRootLogger();
183
+    /**
184
+     * Reset all values contained in this hierarchy instance to their
185
+     * default. 
186
+     *
187
+     * This removes all appenders from all loggers, sets
188
+     * the level of all non-root loggers to <i>null</i>,
189
+     * sets their additivity flag to <i>true</i> and sets the level
190
+     * of the root logger to {@link LOGGER_LEVEL_DEBUG}.
191
+     * 
192
+     * <p>Existing loggers are not removed. They are just reset.
193
+     *
194
+     * <p>This method should be used sparingly and with care as it will
195
+     * block all logging until it is completed.</p>
196
+     */
197
+    public function resetConfiguration() {
198
+        $root = $this->getRootLogger();
199 199
 		
200
-		$root->setLevel(Payone_Log4php_LoggerLevel::getLevelDebug());
201
-		$this->setThreshold(Payone_Log4php_LoggerLevel::getLevelAll());
202
-		$this->shutDown();
200
+        $root->setLevel(Payone_Log4php_LoggerLevel::getLevelDebug());
201
+        $this->setThreshold(Payone_Log4php_LoggerLevel::getLevelAll());
202
+        $this->shutDown();
203 203
 		
204
-		foreach($this->loggers as $logger) {
205
-			$logger->setLevel(null);
206
-			$logger->setAdditivity(true);
207
-			$logger->removeAllAppenders();
208
-		}
204
+        foreach($this->loggers as $logger) {
205
+            $logger->setLevel(null);
206
+            $logger->setAdditivity(true);
207
+            $logger->removeAllAppenders();
208
+        }
209 209
 		
210
-		$this->rendererMap->clear();
211
-		Payone_Log4php_LoggerAppenderPool::clear();
212
-	}
210
+        $this->rendererMap->clear();
211
+        Payone_Log4php_LoggerAppenderPool::clear();
212
+    }
213 213
 	
214
-	/**
215
-	 * Sets the main threshold level.
216
-	 * @param Payone_Log4php_LoggerLevel $l
217
-	 */
218
-	public function setThreshold(Payone_Log4php_LoggerLevel $threshold) {
219
-		$this->threshold = $threshold;
220
-	}
214
+    /**
215
+     * Sets the main threshold level.
216
+     * @param Payone_Log4php_LoggerLevel $l
217
+     */
218
+    public function setThreshold(Payone_Log4php_LoggerLevel $threshold) {
219
+        $this->threshold = $threshold;
220
+    }
221 221
 	
222
-	/**
223
-	 * Shutting down a hierarchy will <i>safely</i> close and remove
224
-	 * all appenders in all loggers including the root logger.
225
-	 * 
226
-	 * The shutdown method is careful to close nested
227
-	 * appenders before closing regular appenders. This is allows
228
-	 * configurations where a regular appender is attached to a logger
229
-	 * and again to a nested appender.
230
-	 * 
231
-	 * @todo Check if the last paragraph is correct.
232
-	 */
233
-	public function shutdown() {
234
-		$this->root->removeAllAppenders();
222
+    /**
223
+     * Shutting down a hierarchy will <i>safely</i> close and remove
224
+     * all appenders in all loggers including the root logger.
225
+     * 
226
+     * The shutdown method is careful to close nested
227
+     * appenders before closing regular appenders. This is allows
228
+     * configurations where a regular appender is attached to a logger
229
+     * and again to a nested appender.
230
+     * 
231
+     * @todo Check if the last paragraph is correct.
232
+     */
233
+    public function shutdown() {
234
+        $this->root->removeAllAppenders();
235 235
 		
236
-		foreach($this->loggers as $logger) {
237
-			$logger->removeAllAppenders();
238
-		}
239
-	}
236
+        foreach($this->loggers as $logger) {
237
+            $logger->removeAllAppenders();
238
+        }
239
+    }
240 240
 } 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
 	 * @return Logger Logger instance.
113 113
 	 */
114 114
 	public function getLogger($name) {
115
-		if(!isset($this->loggers[$name])) {
115
+		if (!isset($this->loggers[$name])) {
116 116
 			$logger = new Payone_Log4php_Logger($name);
117 117
 
118 118
 			$nodes = explode('.', $name);
119 119
 			$firstNode = array_shift($nodes);
120 120
 			
121 121
 			// if name is not a first node but another first node is their
122
-			if($firstNode != $name and isset($this->loggers[$firstNode])) {
122
+			if ($firstNode != $name and isset($this->loggers[$firstNode])) {
123 123
 				$logger->setParent($this->loggers[$firstNode]);
124 124
 			} else {
125 125
 				// if there is no father, set root logger as father
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 			} 
128 128
 		
129 129
 			// if there are more nodes than one
130
-			if(count($nodes) > 0) {
130
+			if (count($nodes) > 0) {
131 131
 				// find parent node
132
-				foreach($nodes as $node) {
132
+				foreach ($nodes as $node) {
133 133
 					$parentNode = "$firstNode.$node";
134
-					if(isset($this->loggers[$parentNode]) and $parentNode != $name) {
134
+					if (isset($this->loggers[$parentNode]) and $parentNode != $name) {
135 135
 						$logger->setParent($this->loggers[$parentNode]);
136 136
 					}
137 137
 					$firstNode .= ".$node";
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return Payone_Log4php_LoggerRoot
158 158
 	 */ 
159 159
 	public function getRootLogger() {
160
-		if(!isset($this->root) or $this->root == null) {
160
+		if (!isset($this->root) or $this->root == null) {
161 161
 			$this->root = new Payone_Log4php_LoggerRoot();
162 162
 		}
163 163
 		return $this->root;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		$this->setThreshold(Payone_Log4php_LoggerLevel::getLevelAll());
202 202
 		$this->shutDown();
203 203
 		
204
-		foreach($this->loggers as $logger) {
204
+		foreach ($this->loggers as $logger) {
205 205
 			$logger->setLevel(null);
206 206
 			$logger->setAdditivity(true);
207 207
 			$logger->removeAllAppenders();
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	public function shutdown() {
234 234
 		$this->root->removeAllAppenders();
235 235
 		
236
-		foreach($this->loggers as $logger) {
236
+		foreach ($this->loggers as $logger) {
237 237
 			$logger->removeAllAppenders();
238 238
 		}
239 239
 	}
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerLevel.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	/**
74 74
 	 * Compares two logger levels.
75 75
 	 *
76
-	 * @param LoggerLevels $other
77
-	 * @return boolean 
76
+	 * @param Payone_Log4php_LoggerLevel $other
77
+	 * @return boolean|null 
78 78
 	 */
79 79
 	public function equals($other) {
80 80
 		if($other instanceof Payone_Log4php_LoggerLevel) {
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * this method returns the provided default level.
224 224
 	 *
225 225
 	 * @param mixed $arg The value to convert to level.
226
-	 * @param Payone_Log4php_LoggerLevel $default Value to return if conversion is not possible.
226
+	 * @param Payone_Log4php_LoggerLevel $defaultLevel Value to return if conversion is not possible.
227 227
 	 * @return Payone_Log4php_LoggerLevel
228 228
 	 */
229 229
 	public static function toLevel($arg, $defaultLevel = null) {
Please login to merge, or discard this patch.
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -33,224 +33,224 @@
 block discarded – undo
33 33
  */
34 34
 class Payone_Log4php_LoggerLevel {
35 35
 	
36
-	const OFF = 2147483647;
37
-	const FATAL = 50000;
38
-	const ERROR = 40000;
39
-	const WARN = 30000;
40
-	const INFO = 20000;
41
-	const DEBUG = 10000;
42
-	const TRACE = 5000;
43
-	const ALL = -2147483647;
36
+    const OFF = 2147483647;
37
+    const FATAL = 50000;
38
+    const ERROR = 40000;
39
+    const WARN = 30000;
40
+    const INFO = 20000;
41
+    const DEBUG = 10000;
42
+    const TRACE = 5000;
43
+    const ALL = -2147483647;
44 44
 
45
-	/** Integer level value. */
46
-	private $level;
45
+    /** Integer level value. */
46
+    private $level;
47 47
 	
48
-	/** Contains a list of instantiated levels. */
49
-	private static $levelMap;
48
+    /** Contains a list of instantiated levels. */
49
+    private static $levelMap;
50 50
 
51
-	/** String representation of the level. */
52
-	private $levelStr;
51
+    /** String representation of the level. */
52
+    private $levelStr;
53 53
 
54
-	/** 
55
-	 * Equivalent syslog level.
56
-	 * @var integer
57
-	 */
58
-	private $syslogEquivalent;
54
+    /** 
55
+     * Equivalent syslog level.
56
+     * @var integer
57
+     */
58
+    private $syslogEquivalent;
59 59
 
60
-	/**
61
-	 * Constructor
62
-	 *
63
-	 * @param integer $level
64
-	 * @param string $levelStr
65
-	 * @param integer $syslogEquivalent
66
-	 */
67
-	private function __construct($level, $levelStr, $syslogEquivalent) {
68
-		$this->level = $level;
69
-		$this->levelStr = $levelStr;
70
-		$this->syslogEquivalent = $syslogEquivalent;
71
-	}
60
+    /**
61
+     * Constructor
62
+     *
63
+     * @param integer $level
64
+     * @param string $levelStr
65
+     * @param integer $syslogEquivalent
66
+     */
67
+    private function __construct($level, $levelStr, $syslogEquivalent) {
68
+        $this->level = $level;
69
+        $this->levelStr = $levelStr;
70
+        $this->syslogEquivalent = $syslogEquivalent;
71
+    }
72 72
 
73
-	/**
74
-	 * Compares two logger levels.
75
-	 *
76
-	 * @param LoggerLevels $other
77
-	 * @return boolean 
78
-	 */
79
-	public function equals($other) {
80
-		if($other instanceof Payone_Log4php_LoggerLevel) {
81
-			if($this->level == $other->level) {
82
-				return true;
83
-			}
84
-		} else {
85
-			return false;
86
-		}
87
-	}
73
+    /**
74
+     * Compares two logger levels.
75
+     *
76
+     * @param LoggerLevels $other
77
+     * @return boolean 
78
+     */
79
+    public function equals($other) {
80
+        if($other instanceof Payone_Log4php_LoggerLevel) {
81
+            if($this->level == $other->level) {
82
+                return true;
83
+            }
84
+        } else {
85
+            return false;
86
+        }
87
+    }
88 88
 	
89
-	/**
90
-	 * Returns an Off Level
91
-	 * @return Payone_Log4php_LoggerLevel
92
-	 */
93
-	public static function getLevelOff() {
94
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::OFF])) {
95
-			self::$levelMap[Payone_Log4php_LoggerLevel::OFF] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::OFF, 'OFF', LOG_ALERT);
96
-		}
97
-		return self::$levelMap[Payone_Log4php_LoggerLevel::OFF];
98
-	}
89
+    /**
90
+     * Returns an Off Level
91
+     * @return Payone_Log4php_LoggerLevel
92
+     */
93
+    public static function getLevelOff() {
94
+        if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::OFF])) {
95
+            self::$levelMap[Payone_Log4php_LoggerLevel::OFF] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::OFF, 'OFF', LOG_ALERT);
96
+        }
97
+        return self::$levelMap[Payone_Log4php_LoggerLevel::OFF];
98
+    }
99 99
 
100
-	/**
101
-	 * Returns a Fatal Level
102
-	 * @return Payone_Log4php_LoggerLevel
103
-	 */
104
-	public static function getLevelFatal() {
105
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::FATAL])) {
106
-			self::$levelMap[Payone_Log4php_LoggerLevel::FATAL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
107
-		}
108
-		return self::$levelMap[Payone_Log4php_LoggerLevel::FATAL];
109
-	}
100
+    /**
101
+     * Returns a Fatal Level
102
+     * @return Payone_Log4php_LoggerLevel
103
+     */
104
+    public static function getLevelFatal() {
105
+        if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::FATAL])) {
106
+            self::$levelMap[Payone_Log4php_LoggerLevel::FATAL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
107
+        }
108
+        return self::$levelMap[Payone_Log4php_LoggerLevel::FATAL];
109
+    }
110 110
 	
111
-	/**
112
-	 * Returns an Error Level
113
-	 * @return Payone_Log4php_LoggerLevel
114
-	 */
115
-	public static function getLevelError() {
116
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ERROR])) {
117
-			self::$levelMap[Payone_Log4php_LoggerLevel::ERROR] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ERROR, 'ERROR', LOG_ERR);
118
-		}
119
-		return self::$levelMap[Payone_Log4php_LoggerLevel::ERROR];
120
-	}
111
+    /**
112
+     * Returns an Error Level
113
+     * @return Payone_Log4php_LoggerLevel
114
+     */
115
+    public static function getLevelError() {
116
+        if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ERROR])) {
117
+            self::$levelMap[Payone_Log4php_LoggerLevel::ERROR] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ERROR, 'ERROR', LOG_ERR);
118
+        }
119
+        return self::$levelMap[Payone_Log4php_LoggerLevel::ERROR];
120
+    }
121 121
 	
122
-	/**
123
-	 * Returns a Warn Level
124
-	 * @return Payone_Log4php_LoggerLevel
125
-	 */
126
-	public static function getLevelWarn() {
127
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::WARN])) {
128
-			self::$levelMap[Payone_Log4php_LoggerLevel::WARN] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::WARN, 'WARN', LOG_WARNING);
129
-		}
130
-		return self::$levelMap[Payone_Log4php_LoggerLevel::WARN];
131
-	}
122
+    /**
123
+     * Returns a Warn Level
124
+     * @return Payone_Log4php_LoggerLevel
125
+     */
126
+    public static function getLevelWarn() {
127
+        if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::WARN])) {
128
+            self::$levelMap[Payone_Log4php_LoggerLevel::WARN] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::WARN, 'WARN', LOG_WARNING);
129
+        }
130
+        return self::$levelMap[Payone_Log4php_LoggerLevel::WARN];
131
+    }
132 132
 
133
-	/**
134
-	 * Returns an Info Level
135
-	 * @return Payone_Log4php_LoggerLevel
136
-	 */
137
-	public static function getLevelInfo() {
138
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::INFO])) {
139
-			self::$levelMap[Payone_Log4php_LoggerLevel::INFO] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::INFO, 'INFO', LOG_INFO);
140
-		}
141
-		return self::$levelMap[Payone_Log4php_LoggerLevel::INFO];
142
-	}
133
+    /**
134
+     * Returns an Info Level
135
+     * @return Payone_Log4php_LoggerLevel
136
+     */
137
+    public static function getLevelInfo() {
138
+        if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::INFO])) {
139
+            self::$levelMap[Payone_Log4php_LoggerLevel::INFO] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::INFO, 'INFO', LOG_INFO);
140
+        }
141
+        return self::$levelMap[Payone_Log4php_LoggerLevel::INFO];
142
+    }
143 143
 
144
-	/**
145
-	 * Returns a Debug Level
146
-	 * @return Payone_Log4php_LoggerLevel
147
-	 */
148
-	public static function getLevelDebug() {
149
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG])) {
150
-			self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
151
-		}
152
-		return self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG];
153
-	}
144
+    /**
145
+     * Returns a Debug Level
146
+     * @return Payone_Log4php_LoggerLevel
147
+     */
148
+    public static function getLevelDebug() {
149
+        if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG])) {
150
+            self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
151
+        }
152
+        return self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG];
153
+    }
154 154
 	
155
-	/**
156
-	 * Returns a Trace Level
157
-	 * @return Payone_Log4php_LoggerLevel
158
-	 */
159
-	public static function getLevelTrace() {
160
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::TRACE])) {
161
-			self::$levelMap[Payone_Log4php_LoggerLevel::TRACE] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
162
-		}
163
-		return self::$levelMap[Payone_Log4php_LoggerLevel::TRACE];
164
-	}	
155
+    /**
156
+     * Returns a Trace Level
157
+     * @return Payone_Log4php_LoggerLevel
158
+     */
159
+    public static function getLevelTrace() {
160
+        if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::TRACE])) {
161
+            self::$levelMap[Payone_Log4php_LoggerLevel::TRACE] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
162
+        }
163
+        return self::$levelMap[Payone_Log4php_LoggerLevel::TRACE];
164
+    }	
165 165
 
166
-	/**
167
-	 * Returns an All Level
168
-	 * @return Payone_Log4php_LoggerLevel
169
-	 */
170
-	public static function getLevelAll() {
171
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ALL])) {
172
-			self::$levelMap[Payone_Log4php_LoggerLevel::ALL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ALL, 'ALL', LOG_DEBUG);
173
-		}
174
-		return self::$levelMap[Payone_Log4php_LoggerLevel::ALL];
175
-	}
166
+    /**
167
+     * Returns an All Level
168
+     * @return Payone_Log4php_LoggerLevel
169
+     */
170
+    public static function getLevelAll() {
171
+        if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ALL])) {
172
+            self::$levelMap[Payone_Log4php_LoggerLevel::ALL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ALL, 'ALL', LOG_DEBUG);
173
+        }
174
+        return self::$levelMap[Payone_Log4php_LoggerLevel::ALL];
175
+    }
176 176
 	
177
-	/**
178
-	 * Return the syslog equivalent of this priority as an integer.
179
-	 * @return integer
180
-	 */
181
-	public function getSyslogEquivalent() {
182
-		return $this->syslogEquivalent;
183
-	}
177
+    /**
178
+     * Return the syslog equivalent of this priority as an integer.
179
+     * @return integer
180
+     */
181
+    public function getSyslogEquivalent() {
182
+        return $this->syslogEquivalent;
183
+    }
184 184
 
185
-	/**
186
-	 * Returns <i>true</i> if this level has a higher or equal
187
-	 * level than the level passed as argument, <i>false</i>
188
-	 * otherwise.
189
-	 *
190
-	 * @param Payone_Log4php_LoggerLevel $other
191
-	 * @return boolean
192
-	 */
193
-	public function isGreaterOrEqual($other) {
194
-		return $this->level >= $other->level;
195
-	}
185
+    /**
186
+     * Returns <i>true</i> if this level has a higher or equal
187
+     * level than the level passed as argument, <i>false</i>
188
+     * otherwise.
189
+     *
190
+     * @param Payone_Log4php_LoggerLevel $other
191
+     * @return boolean
192
+     */
193
+    public function isGreaterOrEqual($other) {
194
+        return $this->level >= $other->level;
195
+    }
196 196
 
197
-	/**
198
-	 * Returns the string representation of this level.
199
-	 * @return string
200
-	 */
201
-	public function toString() {
202
-		return $this->levelStr;
203
-	}
197
+    /**
198
+     * Returns the string representation of this level.
199
+     * @return string
200
+     */
201
+    public function toString() {
202
+        return $this->levelStr;
203
+    }
204 204
 	
205
-	/**
206
-	 * Returns the string representation of this level.
207
-	 * @return string
208
-	 */
209
-	public function __toString() {
210
-		return $this->toString();
211
-	}
205
+    /**
206
+     * Returns the string representation of this level.
207
+     * @return string
208
+     */
209
+    public function __toString() {
210
+        return $this->toString();
211
+    }
212 212
 
213
-	/**
214
-	 * Returns the integer representation of this level.
215
-	 * @return integer
216
-	 */
217
-	public function toInt() {
218
-		return $this->level;
219
-	}
213
+    /**
214
+     * Returns the integer representation of this level.
215
+     * @return integer
216
+     */
217
+    public function toInt() {
218
+        return $this->level;
219
+    }
220 220
 
221
-	/**
222
-	 * Convert the input argument to a level. If the conversion fails, then 
223
-	 * this method returns the provided default level.
224
-	 *
225
-	 * @param mixed $arg The value to convert to level.
226
-	 * @param Payone_Log4php_LoggerLevel $default Value to return if conversion is not possible.
227
-	 * @return Payone_Log4php_LoggerLevel
228
-	 */
229
-	public static function toLevel($arg, $defaultLevel = null) {
230
-		if(is_int($arg)) {
231
-			switch($arg) {
232
-				case self::ALL:	return self::getLevelAll();
233
-				case self::TRACE: return self::getLevelTrace();
234
-				case self::DEBUG: return self::getLevelDebug();
235
-				case self::INFO: return self::getLevelInfo();
236
-				case self::WARN: return self::getLevelWarn();
237
-				case self::ERROR: return self::getLevelError();
238
-				case self::FATAL: return self::getLevelFatal();
239
-				case self::OFF:	return self::getLevelOff();
240
-				default: return $defaultLevel;
241
-			}
242
-		} else {
243
-			switch(strtoupper($arg)) {
244
-				case 'ALL':	return self::getLevelAll();
245
-				case 'TRACE': return self::getLevelTrace();
246
-				case 'DEBUG': return self::getLevelDebug();
247
-				case 'INFO': return self::getLevelInfo();
248
-				case 'WARN': return self::getLevelWarn();
249
-				case 'ERROR': return self::getLevelError();
250
-				case 'FATAL': return self::getLevelFatal();
251
-				case 'OFF':	return self::getLevelOff();
252
-				default: return $defaultLevel;
253
-			}
254
-		}
255
-	}
221
+    /**
222
+     * Convert the input argument to a level. If the conversion fails, then 
223
+     * this method returns the provided default level.
224
+     *
225
+     * @param mixed $arg The value to convert to level.
226
+     * @param Payone_Log4php_LoggerLevel $default Value to return if conversion is not possible.
227
+     * @return Payone_Log4php_LoggerLevel
228
+     */
229
+    public static function toLevel($arg, $defaultLevel = null) {
230
+        if(is_int($arg)) {
231
+            switch($arg) {
232
+                case self::ALL:	return self::getLevelAll();
233
+                case self::TRACE: return self::getLevelTrace();
234
+                case self::DEBUG: return self::getLevelDebug();
235
+                case self::INFO: return self::getLevelInfo();
236
+                case self::WARN: return self::getLevelWarn();
237
+                case self::ERROR: return self::getLevelError();
238
+                case self::FATAL: return self::getLevelFatal();
239
+                case self::OFF:	return self::getLevelOff();
240
+                default: return $defaultLevel;
241
+            }
242
+        } else {
243
+            switch(strtoupper($arg)) {
244
+                case 'ALL':	return self::getLevelAll();
245
+                case 'TRACE': return self::getLevelTrace();
246
+                case 'DEBUG': return self::getLevelDebug();
247
+                case 'INFO': return self::getLevelInfo();
248
+                case 'WARN': return self::getLevelWarn();
249
+                case 'ERROR': return self::getLevelError();
250
+                case 'FATAL': return self::getLevelFatal();
251
+                case 'OFF':	return self::getLevelOff();
252
+                default: return $defaultLevel;
253
+            }
254
+        }
255
+    }
256 256
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 * @return boolean 
78 78
 	 */
79 79
 	public function equals($other) {
80
-		if($other instanceof Payone_Log4php_LoggerLevel) {
81
-			if($this->level == $other->level) {
80
+		if ($other instanceof Payone_Log4php_LoggerLevel) {
81
+			if ($this->level == $other->level) {
82 82
 				return true;
83 83
 			}
84 84
 		} else {
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return Payone_Log4php_LoggerLevel
92 92
 	 */
93 93
 	public static function getLevelOff() {
94
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::OFF])) {
94
+		if (!isset(self::$levelMap[Payone_Log4php_LoggerLevel::OFF])) {
95 95
 			self::$levelMap[Payone_Log4php_LoggerLevel::OFF] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::OFF, 'OFF', LOG_ALERT);
96 96
 		}
97 97
 		return self::$levelMap[Payone_Log4php_LoggerLevel::OFF];
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @return Payone_Log4php_LoggerLevel
103 103
 	 */
104 104
 	public static function getLevelFatal() {
105
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::FATAL])) {
105
+		if (!isset(self::$levelMap[Payone_Log4php_LoggerLevel::FATAL])) {
106 106
 			self::$levelMap[Payone_Log4php_LoggerLevel::FATAL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::FATAL, 'FATAL', LOG_ALERT);
107 107
 		}
108 108
 		return self::$levelMap[Payone_Log4php_LoggerLevel::FATAL];
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @return Payone_Log4php_LoggerLevel
114 114
 	 */
115 115
 	public static function getLevelError() {
116
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ERROR])) {
116
+		if (!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ERROR])) {
117 117
 			self::$levelMap[Payone_Log4php_LoggerLevel::ERROR] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ERROR, 'ERROR', LOG_ERR);
118 118
 		}
119 119
 		return self::$levelMap[Payone_Log4php_LoggerLevel::ERROR];
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return Payone_Log4php_LoggerLevel
125 125
 	 */
126 126
 	public static function getLevelWarn() {
127
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::WARN])) {
127
+		if (!isset(self::$levelMap[Payone_Log4php_LoggerLevel::WARN])) {
128 128
 			self::$levelMap[Payone_Log4php_LoggerLevel::WARN] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::WARN, 'WARN', LOG_WARNING);
129 129
 		}
130 130
 		return self::$levelMap[Payone_Log4php_LoggerLevel::WARN];
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return Payone_Log4php_LoggerLevel
136 136
 	 */
137 137
 	public static function getLevelInfo() {
138
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::INFO])) {
138
+		if (!isset(self::$levelMap[Payone_Log4php_LoggerLevel::INFO])) {
139 139
 			self::$levelMap[Payone_Log4php_LoggerLevel::INFO] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::INFO, 'INFO', LOG_INFO);
140 140
 		}
141 141
 		return self::$levelMap[Payone_Log4php_LoggerLevel::INFO];
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @return Payone_Log4php_LoggerLevel
147 147
 	 */
148 148
 	public static function getLevelDebug() {
149
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG])) {
149
+		if (!isset(self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG])) {
150 150
 			self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::DEBUG, 'DEBUG', LOG_DEBUG);
151 151
 		}
152 152
 		return self::$levelMap[Payone_Log4php_LoggerLevel::DEBUG];
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return Payone_Log4php_LoggerLevel
158 158
 	 */
159 159
 	public static function getLevelTrace() {
160
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::TRACE])) {
160
+		if (!isset(self::$levelMap[Payone_Log4php_LoggerLevel::TRACE])) {
161 161
 			self::$levelMap[Payone_Log4php_LoggerLevel::TRACE] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::TRACE, 'TRACE', LOG_DEBUG);
162 162
 		}
163 163
 		return self::$levelMap[Payone_Log4php_LoggerLevel::TRACE];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @return Payone_Log4php_LoggerLevel
169 169
 	 */
170 170
 	public static function getLevelAll() {
171
-		if(!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ALL])) {
171
+		if (!isset(self::$levelMap[Payone_Log4php_LoggerLevel::ALL])) {
172 172
 			self::$levelMap[Payone_Log4php_LoggerLevel::ALL] = new Payone_Log4php_LoggerLevel(Payone_Log4php_LoggerLevel::ALL, 'ALL', LOG_DEBUG);
173 173
 		}
174 174
 		return self::$levelMap[Payone_Log4php_LoggerLevel::ALL];
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 	 * @return Payone_Log4php_LoggerLevel
228 228
 	 */
229 229
 	public static function toLevel($arg, $defaultLevel = null) {
230
-		if(is_int($arg)) {
231
-			switch($arg) {
230
+		if (is_int($arg)) {
231
+			switch ($arg) {
232 232
 				case self::ALL:	return self::getLevelAll();
233 233
 				case self::TRACE: return self::getLevelTrace();
234 234
 				case self::DEBUG: return self::getLevelDebug();
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 				default: return $defaultLevel;
241 241
 			}
242 242
 		} else {
243
-			switch(strtoupper($arg)) {
243
+			switch (strtoupper($arg)) {
244 244
 				case 'ALL':	return self::getLevelAll();
245 245
 				case 'TRACE': return self::getLevelTrace();
246 246
 				case 'DEBUG': return self::getLevelDebug();
Please login to merge, or discard this patch.
lib/Payone/Log4php/LoggerLocationInfo.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 	 * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
63 63
 	 *
64 64
 	 * @param array $trace
65
-	 * @param mixed $caller
65
+	 * @param string $fqcn
66 66
 	 */
67 67
 	public function __construct($trace, $fqcn = null) {
68 68
 		$this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -26,85 +26,85 @@
 block discarded – undo
26 26
  * @since 0.3
27 27
  */
28 28
 class Payone_Log4php_LoggerLocationInfo {
29
-	/**
30
-	 * When location information is not available the constant
31
-	 * <i>NA</i> is returned. Current value of this string
32
-	 * constant is <b>?</b>.  
33
-	 */
34
-	const LOCATION_INFO_NA = 'NA';
29
+    /**
30
+     * When location information is not available the constant
31
+     * <i>NA</i> is returned. Current value of this string
32
+     * constant is <b>?</b>.  
33
+     */
34
+    const LOCATION_INFO_NA = 'NA';
35 35
 	
36
-	/**
37
-	* @var string Caller's line number.
38
-	*/
39
-	protected $lineNumber = null;
36
+    /**
37
+     * @var string Caller's line number.
38
+     */
39
+    protected $lineNumber = null;
40 40
 	
41
-	/**
42
-	* @var string Caller's file name.
43
-	*/
44
-	protected $fileName = null;
41
+    /**
42
+     * @var string Caller's file name.
43
+     */
44
+    protected $fileName = null;
45 45
 	
46
-	/**
47
-	* @var string Caller's fully qualified class name.
48
-	*/
49
-	protected $className = null;
46
+    /**
47
+     * @var string Caller's fully qualified class name.
48
+     */
49
+    protected $className = null;
50 50
 	
51
-	/**
52
-	* @var string Caller's method name.
53
-	*/
54
-	protected $methodName = null;
51
+    /**
52
+     * @var string Caller's method name.
53
+     */
54
+    protected $methodName = null;
55 55
 	
56
-	/**
57
-	* @var string 
58
-	*/
59
-	protected $fullInfo = null;
56
+    /**
57
+     * @var string 
58
+     */
59
+    protected $fullInfo = null;
60 60
 
61
-	/**
62
-	 * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
63
-	 *
64
-	 * @param array $trace
65
-	 * @param mixed $caller
66
-	 */
67
-	public function __construct($trace, $fqcn = null) {
68
-		$this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
69
-		$this->fileName = isset($trace['file']) ? $trace['file'] : null;
70
-		$this->className = isset($trace['class']) ? $trace['class'] : null;
71
-		$this->methodName = isset($trace['function']) ? $trace['function'] : null;
72
-		$this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . 
73
-			'(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
74
-	}
61
+    /**
62
+     * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
63
+     *
64
+     * @param array $trace
65
+     * @param mixed $caller
66
+     */
67
+    public function __construct($trace, $fqcn = null) {
68
+        $this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
69
+        $this->fileName = isset($trace['file']) ? $trace['file'] : null;
70
+        $this->className = isset($trace['class']) ? $trace['class'] : null;
71
+        $this->methodName = isset($trace['function']) ? $trace['function'] : null;
72
+        $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . 
73
+            '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
74
+    }
75 75
 
76
-	public function getClassName() {
77
-		return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className; 
78
-	}
76
+    public function getClassName() {
77
+        return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className; 
78
+    }
79 79
 
80
-	/**
81
-	 *	Return the file name of the caller.
82
-	 *	<p>This information is not always available.
83
-	 */
84
-	public function getFileName() {
85
-		return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName; 
86
-	}
80
+    /**
81
+     *	Return the file name of the caller.
82
+     *	<p>This information is not always available.
83
+     */
84
+    public function getFileName() {
85
+        return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName; 
86
+    }
87 87
 
88
-	/**
89
-	 *	Returns the line number of the caller.
90
-	 *	<p>This information is not always available.
91
-	 */
92
-	public function getLineNumber() {
93
-		return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber; 
94
-	}
88
+    /**
89
+     *	Returns the line number of the caller.
90
+     *	<p>This information is not always available.
91
+     */
92
+    public function getLineNumber() {
93
+        return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber; 
94
+    }
95 95
 
96
-	/**
97
-	 *	Returns the method name of the caller.
98
-	 */
99
-	public function getMethodName() {
100
-		return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName; 
101
-	}
96
+    /**
97
+     *	Returns the method name of the caller.
98
+     */
99
+    public function getMethodName() {
100
+        return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName; 
101
+    }
102 102
 
103
-	/**
104
-	 *	Returns the full information of the caller.
105
-	 */
106
-	public function getFullInfo() {
107
-		return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
108
-	}
103
+    /**
104
+     *	Returns the full information of the caller.
105
+     */
106
+    public function getFullInfo() {
107
+        return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
108
+    }
109 109
 
110 110
 }
Please login to merge, or discard this patch.