@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | protected $htmlLineBreaks = false; |
| 52 | 52 | |
| 53 | 53 | public function close() { |
| 54 | - if($this->closed != true) { |
|
| 55 | - if(!$this->firstAppend) { |
|
| 54 | + if ($this->closed != true) { |
|
| 55 | + if (!$this->firstAppend) { |
|
| 56 | 56 | echo $this->layout->getFooter(); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
| 63 | - if($this->layout !== null) { |
|
| 64 | - if($this->firstAppend) { |
|
| 63 | + if ($this->layout !== null) { |
|
| 64 | + if ($this->firstAppend) { |
|
| 65 | 65 | echo $this->layout->getHeader(); |
| 66 | 66 | $this->firstAppend = false; |
| 67 | 67 | } |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | * @param $filter - the filter to add to this chain |
| 109 | 109 | */ |
| 110 | 110 | public function addNext($filter) { |
| 111 | - if($this->next !== null) { |
|
| 111 | + if ($this->next !== null) { |
|
| 112 | 112 | $this->next->addNext($filter); |
| 113 | 113 | } else { |
| 114 | 114 | $this->next = $filter; |
@@ -92,8 +92,8 @@ |
||
| 92 | 92 | /** Setter function for string type. */ |
| 93 | 93 | protected function setString($property, $value, $nullable = false) { |
| 94 | 94 | if ($value === null) { |
| 95 | - if($nullable) { |
|
| 96 | - $this->$property= null; |
|
| 95 | + if ($nullable) { |
|
| 96 | + $this->$property = null; |
|
| 97 | 97 | } else { |
| 98 | 98 | $this->warn("Null value given for '$property' property. Expected a string. Property not changed."); |
| 99 | 99 | } |
@@ -109,15 +109,15 @@ discard block |
||
| 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 |
||
| 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; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public function activateOptions() { |
| 39 | 39 | // Parse the option (desired output length) |
| 40 | 40 | if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) { |
| 41 | - $this->length = (integer) $this->option; |
|
| 41 | + $this->length = (integer)$this->option; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | return $name; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - foreach($fragments as $key => &$fragment) { |
|
| 88 | + foreach ($fragments as $key => &$fragment) { |
|
| 89 | 89 | |
| 90 | 90 | // Never shorten last fragment |
| 91 | 91 | if ($key == $count - 1) { |
@@ -87,11 +87,11 @@ |
||
| 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; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | class Payone_Log4php_LoggerAppenderPool { |
| 33 | 33 | |
| 34 | 34 | /** Holds appenders indexed by their name */ |
| 35 | - public static $appenders = array(); |
|
| 35 | + public static $appenders = array(); |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Adds an appender to the pool. |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $name = $appender->getName(); |
| 45 | 45 | |
| 46 | - if(empty($name)) { |
|
| 46 | + if (empty($name)) { |
|
| 47 | 47 | trigger_error('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING); |
| 48 | 48 | return; |
| 49 | 49 | } |
@@ -94,6 +94,6 @@ discard block |
||
| 94 | 94 | * Clears all appenders from the pool. |
| 95 | 95 | */ |
| 96 | 96 | public static function clear() { |
| 97 | - self::$appenders = array(); |
|
| 97 | + self::$appenders = array(); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | \ No newline at end of file |
@@ -111,11 +111,11 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public function setSubject($subject) { |
| 114 | - $this->setString('subject', $subject); |
|
| 114 | + $this->setString('subject', $subject); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function setTo($to) { |
| 118 | - $this->setString('to', $to); |
|
| 118 | + $this->setString('to', $to); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public function setDry($dry) { |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | public function append(Payone_Log4php_LoggerLoggingEvent $event) { |
| 126 | 126 | $smtpHost = $this->smtpHost; |
| 127 | 127 | $prevSmtpHost = ini_get('SMTP'); |
| 128 | - if(!empty($smtpHost)) { |
|
| 128 | + if (!empty($smtpHost)) { |
|
| 129 | 129 | ini_set('SMTP', $smtpHost); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $smtpPort = $this->port; |
| 133 | - $prevSmtpPort= ini_get('smtp_port'); |
|
| 134 | - if($smtpPort > 0 and $smtpPort < 65535) { |
|
| 133 | + $prevSmtpPort = ini_get('smtp_port'); |
|
| 134 | + if ($smtpPort > 0 and $smtpPort < 65535) { |
|
| 135 | 135 | ini_set('smtp_port', $smtpPort); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n"; |
| 141 | 141 | |
| 142 | - if(!$this->dry) { |
|
| 142 | + if (!$this->dry) { |
|
| 143 | 143 | $result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader); |
| 144 | 144 | } else { |
| 145 | - echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event); |
|
| 145 | + echo "DRY MODE OF MAIL APP.: Send mail to: " . $this->to . " with additional headers '" . trim($addHeader) . "' and content: " . $this->layout->format($event); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | ini_set('SMTP', $prevSmtpHost); |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | * value if there is no property with that key. |
| 60 | 60 | */ |
| 61 | 61 | public static function getSystemProperty($key, $def) { |
| 62 | - if(defined($key)) { |
|
| 62 | + if (defined($key)) { |
|
| 63 | 63 | return (string)constant($key); |
| 64 | - } else if(isset($_SERVER[$key])) { |
|
| 64 | + } else if (isset($_SERVER[$key])) { |
|
| 65 | 65 | return (string)$_SERVER[$key]; |
| 66 | - } else if(isset($_ENV[$key])) { |
|
| 66 | + } else if (isset($_ENV[$key])) { |
|
| 67 | 67 | return (string)$_ENV[$key]; |
| 68 | 68 | } else { |
| 69 | 69 | return $def; |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | * @param boolean $default |
| 83 | 83 | * @return boolean |
| 84 | 84 | */ |
| 85 | - public static function toBoolean($value, $default=true) { |
|
| 85 | + public static function toBoolean($value, $default = true) { |
|
| 86 | 86 | if (is_null($value)) { |
| 87 | 87 | return $default; |
| 88 | 88 | } elseif (is_string($value)) { |
| 89 | 89 | $trimmedVal = strtolower(trim($value)); |
| 90 | - if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) { |
|
| 90 | + if ("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) { |
|
| 91 | 91 | return true; |
| 92 | 92 | } else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) { |
| 93 | 93 | return false; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public static function toInt($value, $default) { |
| 128 | 128 | $value = trim($value); |
| 129 | - if(is_numeric($value)) { |
|
| 129 | + if (is_numeric($value)) { |
|
| 130 | 130 | return (int)$value; |
| 131 | 131 | } else { |
| 132 | 132 | return $default; |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | if (is_integer($value)) { |
| 143 | 143 | return $value; |
| 144 | 144 | } |
| 145 | - if (is_numeric($value) && ($value == (integer) $value)) { |
|
| 146 | - return (integer) $value; |
|
| 145 | + if (is_numeric($value) && ($value == (integer)$value)) { |
|
| 146 | + return (integer)$value; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to integer."); |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | if (is_integer($value) && $value > 0) { |
| 158 | 158 | return $value; |
| 159 | 159 | } |
| 160 | - if (is_numeric($value) && ($value == (integer) $value) && $value > 0) { |
|
| 161 | - return (integer) $value; |
|
| 160 | + if (is_numeric($value) && ($value == (integer)$value) && $value > 0) { |
|
| 161 | + return (integer)$value; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer."); |
@@ -191,12 +191,12 @@ discard block |
||
| 191 | 191 | * @return Payone_Log4php_LoggerLevel a {@link LoggerLevel} or null |
| 192 | 192 | */ |
| 193 | 193 | public static function toLevel($value, $defaultValue) { |
| 194 | - if($value === null) { |
|
| 194 | + if ($value === null) { |
|
| 195 | 195 | return $defaultValue; |
| 196 | 196 | } |
| 197 | 197 | $hashIndex = strpos($value, '#'); |
| 198 | - if($hashIndex === false) { |
|
| 199 | - if("NULL" == strtoupper($value)) { |
|
| 198 | + if ($hashIndex === false) { |
|
| 199 | + if ("NULL" == strtoupper($value)) { |
|
| 200 | 200 | return null; |
| 201 | 201 | } else { |
| 202 | 202 | // no class name specified : use standard Level class |
@@ -210,15 +210,15 @@ discard block |
||
| 210 | 210 | $levelName = substr($value, 0, $hashIndex); |
| 211 | 211 | |
| 212 | 212 | // This is degenerate case but you never know. |
| 213 | - if("NULL" == strtoupper($levelName)) { |
|
| 213 | + if ("NULL" == strtoupper($levelName)) { |
|
| 214 | 214 | return null; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $clazz = basename($clazz); |
| 218 | 218 | |
| 219 | - if(class_exists($clazz)) { |
|
| 219 | + if (class_exists($clazz)) { |
|
| 220 | 220 | $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue); |
| 221 | - if(!$result instanceof Payone_Log4php_LoggerLevel) { |
|
| 221 | + if (!$result instanceof Payone_Log4php_LoggerLevel) { |
|
| 222 | 222 | $result = $defaultValue; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -244,23 +244,23 @@ discard block |
||
| 244 | 244 | * @return float |
| 245 | 245 | */ |
| 246 | 246 | public static function toFileSize($value, $default) { |
| 247 | - if($value === null) { |
|
| 247 | + if ($value === null) { |
|
| 248 | 248 | return $default; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | $s = strtoupper(trim($value)); |
| 252 | 252 | $multiplier = (float)1; |
| 253 | - if(($index = strpos($s, 'KB')) !== false) { |
|
| 253 | + if (($index = strpos($s, 'KB')) !== false) { |
|
| 254 | 254 | $multiplier = 1024; |
| 255 | 255 | $s = substr($s, 0, $index); |
| 256 | - } else if(($index = strpos($s, 'MB')) !== false) { |
|
| 256 | + } else if (($index = strpos($s, 'MB')) !== false) { |
|
| 257 | 257 | $multiplier = 1024 * 1024; |
| 258 | 258 | $s = substr($s, 0, $index); |
| 259 | - } else if(($index = strpos($s, 'GB')) !== false) { |
|
| 259 | + } else if (($index = strpos($s, 'GB')) !== false) { |
|
| 260 | 260 | $multiplier = 1024 * 1024 * 1024; |
| 261 | 261 | $s = substr($s, 0, $index); |
| 262 | 262 | } |
| 263 | - if(is_numeric($s)) { |
|
| 263 | + if (is_numeric($s)) { |
|
| 264 | 264 | return (float)$s * $multiplier; |
| 265 | 265 | } |
| 266 | 266 | return $default; |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | if (is_numeric($value)) { |
| 293 | - return (integer) $value; |
|
| 293 | + return (integer)$value; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | if (!is_string($value)) { |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | $size = $matches[1]; |
| 305 | 305 | $unit = $matches[2]; |
| 306 | 306 | |
| 307 | - switch($unit) { |
|
| 307 | + switch ($unit) { |
|
| 308 | 308 | case 'KB': $size *= pow(1024, 1); break; |
| 309 | 309 | case 'MB': $size *= pow(1024, 2); break; |
| 310 | 310 | case 'GB': $size *= pow(1024, 3); break; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - return (integer) $size; |
|
| 313 | + return (integer)$size; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | throw new Payone_Log4php_LoggerException("Given value [$value] cannot be converted to a file size."); |
@@ -328,10 +328,10 @@ discard block |
||
| 328 | 328 | return $value; |
| 329 | 329 | } |
| 330 | 330 | if (is_numeric($value)) { |
| 331 | - return (string) $value; |
|
| 331 | + return (string)$value; |
|
| 332 | 332 | } |
| 333 | 333 | if (is_object($value) && method_exists($value, '__toString')) { |
| 334 | - return (string) $value; |
|
| 334 | + return (string)$value; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | throw new Payone_Log4php_LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string."); |
@@ -406,11 +406,11 @@ discard block |
||
| 406 | 406 | public static function substVars($val, $props = null) { |
| 407 | 407 | $sbuf = ''; |
| 408 | 408 | $i = 0; |
| 409 | - while(true) { |
|
| 409 | + while (true) { |
|
| 410 | 410 | $j = strpos($val, self::DELIM_START, $i); |
| 411 | - if($j === false) { |
|
| 411 | + if ($j === false) { |
|
| 412 | 412 | // no more variables |
| 413 | - if($i == 0) { // this is a simple string |
|
| 413 | + if ($i == 0) { // this is a simple string |
|
| 414 | 414 | return $val; |
| 415 | 415 | } else { // add the tail string which contails no variables and return the result. |
| 416 | 416 | $sbuf .= substr($val, $i); |
@@ -418,9 +418,9 @@ discard block |
||
| 418 | 418 | } |
| 419 | 419 | } else { |
| 420 | 420 | |
| 421 | - $sbuf .= substr($val, $i, $j-$i); |
|
| 421 | + $sbuf .= substr($val, $i, $j - $i); |
|
| 422 | 422 | $k = strpos($val, self::DELIM_STOP, $j); |
| 423 | - if($k === false) { |
|
| 423 | + if ($k === false) { |
|
| 424 | 424 | // LoggerOptionConverter::substVars() has no closing brace. Opening brace |
| 425 | 425 | return ''; |
| 426 | 426 | } else { |
@@ -429,11 +429,11 @@ discard block |
||
| 429 | 429 | // first try in System properties |
| 430 | 430 | $replacement = Payone_Log4php_LoggerOptionConverter::getSystemProperty($key, null); |
| 431 | 431 | // then try props parameter |
| 432 | - if($replacement == null and $props !== null) { |
|
| 432 | + if ($replacement == null and $props !== null) { |
|
| 433 | 433 | $replacement = @$props[$key]; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - if(!empty($replacement)) { |
|
| 436 | + if (!empty($replacement)) { |
|
| 437 | 437 | // Do variable substitution on the replacement string |
| 438 | 438 | // such that we can solve "Hello ${x2}" as "Hello p1" |
| 439 | 439 | // the where the properties are |