@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param string class name |
124 | 124 | */ |
125 | 125 | public static function autoload($className) { |
126 | - if(isset(self::$_classes[$className])) { |
|
126 | + if (isset(self::$_classes[$className])) { |
|
127 | 127 | include LOG4PHP_DIR.self::$_classes[$className]; |
128 | 128 | } |
129 | 129 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return LoggerHierarchy |
200 | 200 | */ |
201 | 201 | public static function getHierarchy() { |
202 | - if(!isset(self::$hierarchy)) { |
|
202 | + if (!isset(self::$hierarchy)) { |
|
203 | 203 | self::$hierarchy = new LoggerHierarchy(new LoggerRoot()); |
204 | 204 | } |
205 | 205 | return self::$hierarchy; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | 291 | public function isEnabledFor($level) { |
292 | - return (bool)($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
292 | + return (bool) ($level->isGreaterOrEqual($this->getEffectiveLevel())); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param mixed $caller caller object or caller string id |
310 | 310 | */ |
311 | 311 | public function log($priority, $message, $caller = null) { |
312 | - if($this->isEnabledFor($priority)) { |
|
312 | + if ($this->isEnabledFor($priority)) { |
|
313 | 313 | $this->forcedLog($this->fqcn, $caller, $priority, $message); |
314 | 314 | } |
315 | 315 | } |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | * @param string $msg message to log |
322 | 322 | */ |
323 | 323 | public function assertLog($assertion = true, $msg = '') { |
324 | - if($assertion == false) { |
|
324 | + if ($assertion == false) { |
|
325 | 325 | $this->error($msg); |
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | 329 | private function logLevel($message, $level, $caller = null) { |
330 | - if($level->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
330 | + if ($level->isGreaterOrEqual($this->getEffectiveLevel())) { |
|
331 | 331 | $this->forcedLog($this->fqcn, $caller, $level, $message); |
332 | 332 | } |
333 | 333 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @static |
344 | 344 | */ |
345 | 345 | public static function getLogger($name) { |
346 | - if(!self::isInitialized()) { |
|
346 | + if (!self::isInitialized()) { |
|
347 | 347 | self::initialize(); |
348 | 348 | } |
349 | 349 | return self::getHierarchy()->getLogger($name); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * @static |
356 | 356 | */ |
357 | 357 | public static function getRootLogger() { |
358 | - if(!self::isInitialized()) { |
|
358 | + if (!self::isInitialized()) { |
|
359 | 359 | self::initialize(); |
360 | 360 | } |
361 | 361 | return self::getHierarchy()->getRootLogger(); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | public function removeAllAppenders() { |
380 | 380 | $appenderNames = array_keys($this->aai); |
381 | 381 | $enumAppenders = count($appenderNames); |
382 | - for($i = 0; $i < $enumAppenders; $i++) { |
|
382 | + for ($i = 0; $i < $enumAppenders; $i++) { |
|
383 | 383 | $this->removeAppender($appenderNames[$i]); |
384 | 384 | } |
385 | 385 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * @param mixed $appender can be an appender name or a {@link LoggerAppender} object |
391 | 391 | */ |
392 | 392 | public function removeAppender($appender) { |
393 | - if($appender instanceof LoggerAppender) { |
|
393 | + if ($appender instanceof LoggerAppender) { |
|
394 | 394 | $appender->close(); |
395 | 395 | unset($this->aai[$appender->getName()]); |
396 | 396 | } else if (is_string($appender) and isset($this->aai[$appender])) { |
@@ -405,12 +405,12 @@ discard block |
||
405 | 405 | * @param LoggerLoggingEvent $event |
406 | 406 | */ |
407 | 407 | public function callAppenders($event) { |
408 | - if(count($this->aai) > 0) { |
|
409 | - foreach(array_keys($this->aai) as $appenderName) { |
|
408 | + if (count($this->aai) > 0) { |
|
409 | + foreach (array_keys($this->aai) as $appenderName) { |
|
410 | 410 | $this->aai[$appenderName]->doAppend($event); |
411 | 411 | } |
412 | 412 | } |
413 | - if($this->parent != null and $this->getAdditivity()) { |
|
413 | + if ($this->parent != null and $this->getAdditivity()) { |
|
414 | 414 | $this->parent->callAppenders($event); |
415 | 415 | } |
416 | 416 | } |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * @return LoggerLevel or null |
446 | 446 | */ |
447 | 447 | public function getEffectiveLevel() { |
448 | - for($c = $this; $c != null; $c = $c->parent) { |
|
449 | - if($c->getLevel() !== null) { |
|
448 | + for ($c = $this; $c != null; $c = $c->parent) { |
|
449 | + if ($c->getLevel() !== null) { |
|
450 | 450 | return $c->getLevel(); |
451 | 451 | } |
452 | 452 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @param boolean $additive |
543 | 543 | */ |
544 | 544 | public function setAdditivity($additive) { |
545 | - $this->additive = (bool)$additive; |
|
545 | + $this->additive = (bool) $additive; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -569,19 +569,19 @@ discard block |
||
569 | 569 | * @param String $configurationClass the configurator class |
570 | 570 | */ |
571 | 571 | public static function configure($configurationFile = null, |
572 | - $configurationClass = null ) { |
|
573 | - if($configurationClass === null && $configurationFile === null) { |
|
572 | + $configurationClass = null) { |
|
573 | + if ($configurationClass === null && $configurationFile === null) { |
|
574 | 574 | self::$configurationClass = 'LoggerConfiguratorBasic'; |
575 | 575 | return; |
576 | 576 | } |
577 | 577 | |
578 | - if($configurationClass !== null) { |
|
578 | + if ($configurationClass !== null) { |
|
579 | 579 | self::$configurationFile = $configurationFile; |
580 | 580 | self::$configurationClass = $configurationClass; |
581 | 581 | return; |
582 | 582 | } |
583 | 583 | |
584 | - if (strtolower(substr( $configurationFile, -4 )) == '.xml') { |
|
584 | + if (strtolower(substr($configurationFile, -4)) == '.xml') { |
|
585 | 585 | self::$configurationFile = $configurationFile; |
586 | 586 | self::$configurationClass = 'LoggerConfiguratorXml'; |
587 | 587 | } else { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param LoggerFilter $newFilter add a new LoggerFilter |
74 | 74 | */ |
75 | 75 | public function addFilter($newFilter) { |
76 | - if($this->filter === null) { |
|
76 | + if ($this->filter === null) { |
|
77 | 77 | $this->filter = $newFilter; |
78 | 78 | } else { |
79 | 79 | $this->filter->addNext($newFilter); |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | * @param LoggerLoggingEvent $event |
116 | 116 | */ |
117 | 117 | public function doAppend(LoggerLoggingEvent $event) { |
118 | - if($this->closed) { |
|
118 | + if ($this->closed) { |
|
119 | 119 | return; |
120 | 120 | } |
121 | 121 | |
122 | - if(!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
122 | + if (!$this->isAsSevereAsThreshold($event->getLevel())) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | $f = $this->getFirstFilter(); |
127 | - while($f !== null) { |
|
127 | + while ($f !== null) { |
|
128 | 128 | switch ($f->decide($event)) { |
129 | 129 | case LoggerFilter::DENY: return; |
130 | 130 | case LoggerFilter::ACCEPT: return $this->append($event); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param LoggerLayout $layout |
141 | 141 | */ |
142 | 142 | public function setLayout($layout) { |
143 | - if($this->requiresLayout()) { |
|
143 | + if ($this->requiresLayout()) { |
|
144 | 144 | $this->layout = $layout; |
145 | 145 | } |
146 | 146 | } |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | * @see LoggerOptionConverter::toLevel() |
214 | 214 | */ |
215 | 215 | public function setThreshold($threshold) { |
216 | - if(is_string($threshold)) { |
|
216 | + if (is_string($threshold)) { |
|
217 | 217 | $this->threshold = LoggerOptionConverter::toLevel($threshold, null); |
218 | - } else if($threshold instanceof LoggerLevel) { |
|
218 | + } else if ($threshold instanceof LoggerLevel) { |
|
219 | 219 | $this->threshold = $threshold; |
220 | 220 | } |
221 | 221 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return boolean true if priority is greater or equal than threshold |
230 | 230 | */ |
231 | 231 | public function isAsSevereAsThreshold($level) { |
232 | - if($this->threshold === null) { |
|
232 | + if ($this->threshold === null) { |
|
233 | 233 | return true; |
234 | 234 | } |
235 | 235 | return $level->isGreaterOrEqual($this->getThreshold()); |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | // TODO: check, if this is really useful |
70 | 70 | public function setProperties($properties, $prefix) { |
71 | 71 | $len = strlen($prefix); |
72 | - while(list($key,) = each($properties)) { |
|
73 | - if(strpos($key, $prefix) === 0) { |
|
74 | - if(strpos($key, '.', ($len + 1)) > 0) { |
|
72 | + while (list($key,) = each($properties)) { |
|
73 | + if (strpos($key, $prefix) === 0) { |
|
74 | + if (strpos($key, '.', ($len + 1)) > 0) { |
|
75 | 75 | continue; |
76 | 76 | } |
77 | 77 | $value = LoggerOptionConverter::findAndSubst($key, $properties); |
78 | 78 | $key = substr($key, $len); |
79 | - if($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
79 | + if ($key == 'layout' and ($this->obj instanceof LoggerAppender)) { |
|
80 | 80 | continue; |
81 | 81 | } |
82 | 82 | $this->setProperty($key, $value); |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | * @param string $value String value of the property |
102 | 102 | */ |
103 | 103 | public function setProperty($name, $value) { |
104 | - if($value === null) { |
|
104 | + if ($value === null) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - $method = "set" . ucfirst($name); |
|
108 | + $method = "set".ucfirst($name); |
|
109 | 109 | |
110 | - if(!method_exists($this->obj, $method)) { |
|
110 | + if (!method_exists($this->obj, $method)) { |
|
111 | 111 | throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!"); |
112 | 112 | } else { |
113 | 113 | return call_user_func(array($this->obj, $method), $value); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | public function activate() { |
118 | - if(method_exists($this->obj, 'activateoptions')) { |
|
118 | + if (method_exists($this->obj, 'activateoptions')) { |
|
119 | 119 | return call_user_func(array($this->obj, 'activateoptions')); |
120 | 120 | } |
121 | 121 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return an object from the class with the given classname |
128 | 128 | */ |
129 | 129 | public static function createObject($class) { |
130 | - if(!empty($class)) { |
|
130 | + if (!empty($class)) { |
|
131 | 131 | $class = basename($class); |
132 | 132 | return new $class(); |
133 | 133 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param LoggerFormattingInfo $fi |
66 | 66 | */ |
67 | 67 | public function __construct($fi = null) { |
68 | - if($fi !== null) { |
|
68 | + if ($fi !== null) { |
|
69 | 69 | $this->min = $fi->min; |
70 | 70 | $this->max = $fi->max; |
71 | 71 | $this->leftAlign = $fi->leftAlign; |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | public function format(&$sbuf, $e) { |
90 | 90 | $s = $this->convert($e); |
91 | 91 | |
92 | - if($s == null or empty($s)) { |
|
93 | - if(0 < $this->min) { |
|
92 | + if ($s == null or empty($s)) { |
|
93 | + if (0 < $this->min) { |
|
94 | 94 | $this->spacePad($sbuf, $this->min); |
95 | 95 | } |
96 | 96 | return; |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | |
99 | 99 | $len = strlen($s); |
100 | 100 | |
101 | - if($len > $this->max) { |
|
102 | - $sbuf .= substr($s , 0, ($len - $this->max)); |
|
103 | - } else if($len < $this->min) { |
|
104 | - if($this->leftAlign) { |
|
101 | + if ($len > $this->max) { |
|
102 | + $sbuf .= substr($s, 0, ($len - $this->max)); |
|
103 | + } else if ($len < $this->min) { |
|
104 | + if ($this->leftAlign) { |
|
105 | 105 | $sbuf .= $s; |
106 | 106 | $this->spacePad($sbuf, ($this->min - $len)); |
107 | 107 | } else { |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | * @todo reimplement using PHP string functions |
123 | 123 | */ |
124 | 124 | public function spacePad($sbuf, $length) { |
125 | - while($length >= 32) { |
|
125 | + while ($length >= 32) { |
|
126 | 126 | $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5]; |
127 | 127 | $length -= 32; |
128 | 128 | } |
129 | 129 | |
130 | - for($i = 4; $i >= 0; $i--) { |
|
131 | - if(($length & (1<<$i)) != 0) { |
|
130 | + for ($i = 4; $i >= 0; $i--) { |
|
131 | + if (($length & (1 << $i)) != 0) { |
|
132 | 132 | $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i]; |
133 | 133 | } |
134 | 134 | } |
@@ -46,8 +46,8 @@ |
||
46 | 46 | */ |
47 | 47 | public function convert($event) { |
48 | 48 | $timeStamp = $event->getTimeStamp(); |
49 | - $usecs = round(($timeStamp - (int)$timeStamp) * 1000); |
|
50 | - $this->df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df); |
|
49 | + $usecs = round(($timeStamp - (int) $timeStamp) * 1000); |
|
50 | + $this->df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}'.sprintf('%03d', $usecs), $this->df); |
|
51 | 51 | return date($this->df, $event->getTimeStamp()); |
52 | 52 | } |
53 | 53 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function __construct($pattern) { |
92 | 92 | $this->pattern = $pattern; |
93 | - $this->patternLength = strlen($pattern); |
|
93 | + $this->patternLength = strlen($pattern); |
|
94 | 94 | $this->formattingInfo = new LoggerFormattingInfo(); |
95 | 95 | $this->state = self::LITERAL_STATE; |
96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param LoggerPatternConverter $pc |
100 | 100 | */ |
101 | 101 | public function addToList($pc) { |
102 | - if($this->head == null) { |
|
102 | + if ($this->head == null) { |
|
103 | 103 | $this->head = $pc; |
104 | 104 | $this->tail = $this->head; |
105 | 105 | } else { |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * @return string |
113 | 113 | */ |
114 | 114 | public function extractOption() { |
115 | - if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
116 | - $end = strpos($this->pattern, '}' , $this->i); |
|
117 | - if($end !== false) { |
|
115 | + if (($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) { |
|
116 | + $end = strpos($this->pattern, '}', $this->i); |
|
117 | + if ($end !== false) { |
|
118 | 118 | $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1)); |
119 | - $this->i= $end + 1; |
|
119 | + $this->i = $end + 1; |
|
120 | 120 | return $r; |
121 | 121 | } |
122 | 122 | } |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | public function extractPrecisionOption() { |
131 | 131 | $opt = $this->extractOption(); |
132 | 132 | $r = 0; |
133 | - if($opt !== null) { |
|
134 | - if(is_numeric($opt)) { |
|
135 | - $r = (int)$opt; |
|
136 | - if($r <= 0) { |
|
133 | + if ($opt !== null) { |
|
134 | + if (is_numeric($opt)) { |
|
135 | + $r = (int) $opt; |
|
136 | + if ($r <= 0) { |
|
137 | 137 | $r = 0; |
138 | 138 | } |
139 | 139 | } |
@@ -150,19 +150,19 @@ discard block |
||
150 | 150 | $c = ''; |
151 | 151 | $this->i = 0; |
152 | 152 | $this->currentLiteral = ''; |
153 | - while($this->i < $this->patternLength) { |
|
153 | + while ($this->i < $this->patternLength) { |
|
154 | 154 | $c = $this->pattern{$this->i++}; |
155 | 155 | |
156 | - switch($this->state) { |
|
156 | + switch ($this->state) { |
|
157 | 157 | case self::LITERAL_STATE: |
158 | 158 | // In literal state, the last char is always a literal. |
159 | - if($this->i == $this->patternLength) { |
|
159 | + if ($this->i == $this->patternLength) { |
|
160 | 160 | $this->currentLiteral .= $c; |
161 | 161 | continue; |
162 | 162 | } |
163 | - if($c == self::ESCAPE_CHAR) { |
|
163 | + if ($c == self::ESCAPE_CHAR) { |
|
164 | 164 | // peek at the next char. |
165 | - switch($this->pattern{$this->i}) { |
|
165 | + switch ($this->pattern{$this->i}) { |
|
166 | 166 | case self::ESCAPE_CHAR: |
167 | 167 | $this->currentLiteral .= $c; |
168 | 168 | $this->i++; // move pointer |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $this->i++; // move pointer |
173 | 173 | break; |
174 | 174 | default: |
175 | - if(strlen($this->currentLiteral) != 0) { |
|
175 | + if (strlen($this->currentLiteral) != 0) { |
|
176 | 176 | $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
177 | 177 | } |
178 | 178 | $this->currentLiteral = $c; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | break; |
186 | 186 | case self::CONVERTER_STATE: |
187 | 187 | $this->currentLiteral .= $c; |
188 | - switch($c) { |
|
188 | + switch ($c) { |
|
189 | 189 | case '-': |
190 | 190 | $this->formattingInfo->leftAlign = true; |
191 | 191 | break; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $this->state = self::DOT_STATE; |
194 | 194 | break; |
195 | 195 | default: |
196 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
196 | + if (ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
197 | 197 | $this->formattingInfo->min = ord($c) - ord('0'); |
198 | 198 | $this->state = self::MIN_STATE; |
199 | 199 | } else { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | break; |
204 | 204 | case self::MIN_STATE: |
205 | 205 | $this->currentLiteral .= $c; |
206 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
206 | + if (ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
207 | 207 | $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0')); |
208 | 208 | } else if ($c == '.') { |
209 | 209 | $this->state = self::DOT_STATE; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | break; |
214 | 214 | case self::DOT_STATE: |
215 | 215 | $this->currentLiteral .= $c; |
216 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
216 | + if (ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
217 | 217 | $this->formattingInfo->max = ord($c) - ord('0'); |
218 | 218 | $this->state = self::MAX_STATE; |
219 | 219 | } else { |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | break; |
223 | 223 | case self::MAX_STATE: |
224 | 224 | $this->currentLiteral .= $c; |
225 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
225 | + if (ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
226 | 226 | $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0')); |
227 | 227 | } else { |
228 | 228 | $this->finalizeConverter($c); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | break; |
232 | 232 | } // switch |
233 | 233 | } // while |
234 | - if(strlen($this->currentLiteral) != 0) { |
|
234 | + if (strlen($this->currentLiteral) != 0) { |
|
235 | 235 | $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral)); |
236 | 236 | } |
237 | 237 | return $this->head; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | public function finalizeConverter($c) { |
241 | 241 | $pc = null; |
242 | - switch($c) { |
|
242 | + switch ($c) { |
|
243 | 243 | case 'c': |
244 | 244 | $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption()); |
245 | 245 | $this->currentLiteral = ''; |
@@ -252,18 +252,18 @@ discard block |
||
252 | 252 | $dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT; |
253 | 253 | $dOpt = $this->extractOption(); |
254 | 254 | |
255 | - if($dOpt !== null) |
|
255 | + if ($dOpt !== null) |
|
256 | 256 | $dateFormatStr = $dOpt; |
257 | 257 | |
258 | - if($dateFormatStr == 'ISO8601') { |
|
258 | + if ($dateFormatStr == 'ISO8601') { |
|
259 | 259 | $df = self::DATE_FORMAT_ISO8601; |
260 | - } else if($dateFormatStr == 'ABSOLUTE') { |
|
260 | + } else if ($dateFormatStr == 'ABSOLUTE') { |
|
261 | 261 | $df = self::DATE_FORMAT_ABSOLUTE; |
262 | - } else if($dateFormatStr == 'DATE') { |
|
262 | + } else if ($dateFormatStr == 'DATE') { |
|
263 | 263 | $df = self::DATE_FORMAT_DATE; |
264 | 264 | } else { |
265 | 265 | $df = $dateFormatStr; |
266 | - if($df == null) { |
|
266 | + if ($df == null) { |
|
267 | 267 | $df = self::DATE_FORMAT_ISO8601; |
268 | 268 | } |
269 | 269 | } |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | $this->currentLiteral = ''; |
304 | 304 | break; |
305 | 305 | case 'u': |
306 | - if($this->i < $this->patternLength) { |
|
306 | + if ($this->i < $this->patternLength) { |
|
307 | 307 | $cNext = $this->pattern{$this->i}; |
308 | - if(ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
309 | - $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0'))); |
|
308 | + if (ord($cNext) >= ord('0') and ord($cNext) <= ord('9')) { |
|
309 | + $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string) (ord($cNext) - ord('0'))); |
|
310 | 310 | $this->currentLiteral = ''; |
311 | 311 | $this->i++; |
312 | 312 | } |
@@ -45,11 +45,11 @@ |
||
45 | 45 | * @return string |
46 | 46 | */ |
47 | 47 | public function convert($event) { |
48 | - switch($this->type) { |
|
48 | + switch ($this->type) { |
|
49 | 49 | case LoggerPatternParser::RELATIVE_TIME_CONVERTER: |
50 | 50 | $timeStamp = $event->getTimeStamp(); |
51 | 51 | $startTime = LoggerLoggingEvent::getStartTime(); |
52 | - return (string)(int)($timeStamp * 1000 - $startTime * 1000); |
|
52 | + return (string) (int) ($timeStamp * 1000 - $startTime * 1000); |
|
53 | 53 | |
54 | 54 | case LoggerPatternParser::THREAD_CONVERTER: |
55 | 55 | return $event->getThreadName(); |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | * @static |
51 | 51 | */ |
52 | 52 | public static function getSystemProperty($key, $def) { |
53 | - if(defined($key)) { |
|
54 | - return (string)constant($key); |
|
55 | - } else if(isset($_SERVER[$key])) { |
|
56 | - return (string)$_SERVER[$key]; |
|
57 | - } else if(isset($_ENV[$key])) { |
|
58 | - return (string)$_ENV[$key]; |
|
53 | + if (defined($key)) { |
|
54 | + return (string) constant($key); |
|
55 | + } else if (isset($_SERVER[$key])) { |
|
56 | + return (string) $_SERVER[$key]; |
|
57 | + } else if (isset($_ENV[$key])) { |
|
58 | + return (string) $_ENV[$key]; |
|
59 | 59 | } else { |
60 | 60 | return $def; |
61 | 61 | } |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @static |
77 | 77 | */ |
78 | - public static function toBoolean($value, $default=true) { |
|
78 | + public static function toBoolean($value, $default = true) { |
|
79 | 79 | if (is_null($value)) { |
80 | 80 | return $default; |
81 | 81 | } elseif (is_string($value)) { |
82 | 82 | $trimmedVal = strtolower(trim($value)); |
83 | 83 | |
84 | - if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) { |
|
84 | + if ("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) { |
|
85 | 85 | return true; |
86 | 86 | } else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) { |
87 | 87 | return false; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | return !($value == 0); // true is everything but 0 like in C |
93 | 93 | } |
94 | 94 | |
95 | - trigger_error("Could not convert ".var_export($value,1)." to boolean!", E_USER_WARNING); |
|
95 | + trigger_error("Could not convert ".var_export($value, 1)." to boolean!", E_USER_WARNING); |
|
96 | 96 | return $default; |
97 | 97 | } |
98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public static function toInt($value, $default) { |
106 | 106 | $value = trim($value); |
107 | - if(is_numeric($value)) { |
|
108 | - return (int)$value; |
|
107 | + if (is_numeric($value)) { |
|
108 | + return (int) $value; |
|
109 | 109 | } else { |
110 | 110 | return $default; |
111 | 111 | } |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | * @static |
140 | 140 | */ |
141 | 141 | public static function toLevel($value, $defaultValue) { |
142 | - if($value === null) { |
|
142 | + if ($value === null) { |
|
143 | 143 | return $defaultValue; |
144 | 144 | } |
145 | 145 | $hashIndex = strpos($value, '#'); |
146 | - if($hashIndex === false) { |
|
147 | - if("NULL" == strtoupper($value)) { |
|
146 | + if ($hashIndex === false) { |
|
147 | + if ("NULL" == strtoupper($value)) { |
|
148 | 148 | return null; |
149 | 149 | } else { |
150 | 150 | // no class name specified : use standard Level class |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | $levelName = substr($value, 0, $hashIndex); |
159 | 159 | |
160 | 160 | // This is degenerate case but you never know. |
161 | - if("NULL" == strtoupper($levelName)) { |
|
161 | + if ("NULL" == strtoupper($levelName)) { |
|
162 | 162 | return null; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $clazz = basename($clazz); |
166 | 166 | |
167 | - if(class_exists($clazz)) { |
|
167 | + if (class_exists($clazz)) { |
|
168 | 168 | $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue); |
169 | - if(!$result instanceof LoggerLevel) { |
|
169 | + if (!$result instanceof LoggerLevel) { |
|
170 | 170 | $result = $defaultValue; |
171 | 171 | } |
172 | 172 | } |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | * @static |
182 | 182 | */ |
183 | 183 | public static function toFileSize($value, $default) { |
184 | - if($value === null) { |
|
184 | + if ($value === null) { |
|
185 | 185 | return $default; |
186 | 186 | } |
187 | 187 | |
188 | 188 | $s = strtoupper(trim($value)); |
189 | - $multiplier = (float)1; |
|
190 | - if(($index = strpos($s, 'KB')) !== false) { |
|
189 | + $multiplier = (float) 1; |
|
190 | + if (($index = strpos($s, 'KB')) !== false) { |
|
191 | 191 | $multiplier = 1024; |
192 | 192 | $s = substr($s, 0, $index); |
193 | - } else if(($index = strpos($s, 'MB')) !== false) { |
|
193 | + } else if (($index = strpos($s, 'MB')) !== false) { |
|
194 | 194 | $multiplier = 1024 * 1024; |
195 | 195 | $s = substr($s, 0, $index); |
196 | - } else if(($index = strpos($s, 'GB')) !== false) { |
|
196 | + } else if (($index = strpos($s, 'GB')) !== false) { |
|
197 | 197 | $multiplier = 1024 * 1024 * 1024; |
198 | 198 | $s = substr($s, 0, $index); |
199 | 199 | } |
200 | - if(is_numeric($s)) { |
|
201 | - return (float)$s * $multiplier; |
|
200 | + if (is_numeric($s)) { |
|
201 | + return (float) $s * $multiplier; |
|
202 | 202 | } |
203 | 203 | return $default; |
204 | 204 | } |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | public static function substVars($val, $props = null) { |
278 | 278 | $sbuf = ''; |
279 | 279 | $i = 0; |
280 | - while(true) { |
|
280 | + while (true) { |
|
281 | 281 | $j = strpos($val, self::DELIM_START, $i); |
282 | - if($j === false) { |
|
282 | + if ($j === false) { |
|
283 | 283 | // no more variables |
284 | - if($i == 0) { // this is a simple string |
|
284 | + if ($i == 0) { // this is a simple string |
|
285 | 285 | return $val; |
286 | 286 | } else { // add the tail string which contails no variables and return the result. |
287 | 287 | $sbuf .= substr($val, $i); |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | } |
290 | 290 | } else { |
291 | 291 | |
292 | - $sbuf .= substr($val, $i, $j-$i); |
|
292 | + $sbuf .= substr($val, $i, $j - $i); |
|
293 | 293 | $k = strpos($val, self::DELIM_STOP, $j); |
294 | - if($k === false) { |
|
294 | + if ($k === false) { |
|
295 | 295 | // LoggerOptionConverter::substVars() has no closing brace. Opening brace |
296 | 296 | return ''; |
297 | 297 | } else { |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | // first try in System properties |
301 | 301 | $replacement = LoggerOptionConverter::getSystemProperty($key, null); |
302 | 302 | // then try props parameter |
303 | - if($replacement == null and $props !== null) { |
|
303 | + if ($replacement == null and $props !== null) { |
|
304 | 304 | $replacement = @$props[$key]; |
305 | 305 | } |
306 | 306 | |
307 | - if(!empty($replacement)) { |
|
307 | + if (!empty($replacement)) { |
|
308 | 308 | // Do variable substitution on the replacement string |
309 | 309 | // such that we can solve "Hello ${x2}" as "Hello p1" |
310 | 310 | // the where the properties are |
@@ -46,7 +46,7 @@ |
||
46 | 46 | */ |
47 | 47 | public function convert($event) { |
48 | 48 | $locationInfo = $event->getLocationInformation(); |
49 | - switch($this->type) { |
|
49 | + switch ($this->type) { |
|
50 | 50 | case LoggerPatternParser::FULL_LOCATION_CONVERTER: |
51 | 51 | return $locationInfo->getFullInfo(); |
52 | 52 | case LoggerPatternParser::METHOD_LOCATION_CONVERTER: |