@@ -55,72 +55,72 @@ |
||
| 55 | 55 | */ |
| 56 | 56 | abstract class Payone_Log4php_LoggerFilter extends Payone_Log4php_LoggerConfigurable { |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * The log event must be logged immediately without consulting with |
|
| 60 | - * the remaining filters, if any, in the chain. |
|
| 61 | - */ |
|
| 62 | - const ACCEPT = 1; |
|
| 58 | + /** |
|
| 59 | + * The log event must be logged immediately without consulting with |
|
| 60 | + * the remaining filters, if any, in the chain. |
|
| 61 | + */ |
|
| 62 | + const ACCEPT = 1; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * This filter is neutral with respect to the log event. The |
|
| 66 | - * remaining filters, if any, should be consulted for a final decision. |
|
| 67 | - */ |
|
| 68 | - const NEUTRAL = 0; |
|
| 64 | + /** |
|
| 65 | + * This filter is neutral with respect to the log event. The |
|
| 66 | + * remaining filters, if any, should be consulted for a final decision. |
|
| 67 | + */ |
|
| 68 | + const NEUTRAL = 0; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * The log event must be dropped immediately without consulting |
|
| 72 | - * with the remaining filters, if any, in the chain. |
|
| 73 | - */ |
|
| 74 | - const DENY = -1; |
|
| 70 | + /** |
|
| 71 | + * The log event must be dropped immediately without consulting |
|
| 72 | + * with the remaining filters, if any, in the chain. |
|
| 73 | + */ |
|
| 74 | + const DENY = -1; |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain. |
|
| 78 | - */ |
|
| 79 | - protected $next; |
|
| 76 | + /** |
|
| 77 | + * @var LoggerFilter Points to the next {@link LoggerFilter} in the filter chain. |
|
| 78 | + */ |
|
| 79 | + protected $next; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Usually filters options become active when set. We provide a |
|
| 83 | - * default do-nothing implementation for convenience. |
|
| 84 | - */ |
|
| 85 | - public function activateOptions() { |
|
| 86 | - } |
|
| 81 | + /** |
|
| 82 | + * Usually filters options become active when set. We provide a |
|
| 83 | + * default do-nothing implementation for convenience. |
|
| 84 | + */ |
|
| 85 | + public function activateOptions() { |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Decide what to do. |
|
| 90 | - * <p>If the decision is {@link LoggerFilter::DENY}, then the event will be |
|
| 91 | - * dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next |
|
| 92 | - * filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then |
|
| 93 | - * the event will be logged without consulting with other filters in |
|
| 94 | - * the chain. |
|
| 95 | - * |
|
| 96 | - * @param Payone_Log4php_LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon. |
|
| 97 | - * @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT} |
|
| 98 | - */ |
|
| 99 | - public function decide(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 100 | - return self::NEUTRAL; |
|
| 101 | - } |
|
| 88 | + /** |
|
| 89 | + * Decide what to do. |
|
| 90 | + * <p>If the decision is {@link LoggerFilter::DENY}, then the event will be |
|
| 91 | + * dropped. If the decision is {@link LoggerFilter::NEUTRAL}, then the next |
|
| 92 | + * filter, if any, will be invoked. If the decision is {@link LoggerFilter::ACCEPT} then |
|
| 93 | + * the event will be logged without consulting with other filters in |
|
| 94 | + * the chain. |
|
| 95 | + * |
|
| 96 | + * @param Payone_Log4php_LoggerLoggingEvent $event The {@link LoggerLoggingEvent} to decide upon. |
|
| 97 | + * @return integer {@link LoggerFilter::NEUTRAL} or {@link LoggerFilter::DENY}|{@link LoggerFilter::ACCEPT} |
|
| 98 | + */ |
|
| 99 | + public function decide(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 100 | + return self::NEUTRAL; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Adds a new filter to the filter chain this filter is a part of. |
|
| 105 | - * If this filter has already and follow up filter, the param filter |
|
| 106 | - * is passed on until it is the last filter in chain. |
|
| 107 | - * |
|
| 108 | - * @param $filter - the filter to add to this chain |
|
| 109 | - */ |
|
| 110 | - public function addNext($filter) { |
|
| 111 | - if($this->next !== null) { |
|
| 112 | - $this->next->addNext($filter); |
|
| 113 | - } else { |
|
| 114 | - $this->next = $filter; |
|
| 115 | - } |
|
| 116 | - } |
|
| 103 | + /** |
|
| 104 | + * Adds a new filter to the filter chain this filter is a part of. |
|
| 105 | + * If this filter has already and follow up filter, the param filter |
|
| 106 | + * is passed on until it is the last filter in chain. |
|
| 107 | + * |
|
| 108 | + * @param $filter - the filter to add to this chain |
|
| 109 | + */ |
|
| 110 | + public function addNext($filter) { |
|
| 111 | + if($this->next !== null) { |
|
| 112 | + $this->next->addNext($filter); |
|
| 113 | + } else { |
|
| 114 | + $this->next = $filter; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Returns the next filter in this chain |
|
| 120 | - * @return the next filter |
|
| 121 | - */ |
|
| 122 | - public function getNext() { |
|
| 123 | - return $this->next; |
|
| 124 | - } |
|
| 118 | + /** |
|
| 119 | + * Returns the next filter in this chain |
|
| 120 | + * @return the next filter |
|
| 121 | + */ |
|
| 122 | + public function getNext() { |
|
| 123 | + return $this->next; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | } |
@@ -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; |
@@ -29,5 +29,5 @@ |
||
| 29 | 29 | * @subpackage pattern |
| 30 | 30 | */ |
| 31 | 31 | class Payone_Log4php_LoggerPatternConverterEnvironment extends Payone_Log4php_LoggerPatternConverterSuperglobal { |
| 32 | - protected $name = '_ENV'; |
|
| 32 | + protected $name = '_ENV'; |
|
| 33 | 33 | } |
@@ -29,5 +29,5 @@ |
||
| 29 | 29 | * @subpackage pattern |
| 30 | 30 | */ |
| 31 | 31 | class Payone_Log4php_LoggerPatternConverterCookie extends Payone_Log4php_LoggerPatternConverterSuperglobal { |
| 32 | - protected $name = '_COOKIE'; |
|
| 32 | + protected $name = '_COOKIE'; |
|
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -39,18 +39,18 @@ |
||
| 39 | 39 | * @subpackage layouts |
| 40 | 40 | */ |
| 41 | 41 | class Payone_Log4php_LoggerLayoutSimple extends Payone_Log4php_LoggerLayout { |
| 42 | - /** |
|
| 43 | - * Returns the log statement in a format consisting of the |
|
| 44 | - * <b>level</b>, followed by " - " and then the |
|
| 45 | - * <b>message</b>. For example, |
|
| 46 | - * <samp> INFO - "A message" </samp> |
|
| 47 | - * |
|
| 48 | - * @param Payone_Log4php_LoggerLoggingEvent $event |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - public function format(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 52 | - $level = $event->getLevel(); |
|
| 53 | - $message = $event->getRenderedMessage(); |
|
| 54 | - return "$level - $message" . PHP_EOL; |
|
| 55 | - } |
|
| 42 | + /** |
|
| 43 | + * Returns the log statement in a format consisting of the |
|
| 44 | + * <b>level</b>, followed by " - " and then the |
|
| 45 | + * <b>message</b>. For example, |
|
| 46 | + * <samp> INFO - "A message" </samp> |
|
| 47 | + * |
|
| 48 | + * @param Payone_Log4php_LoggerLoggingEvent $event |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + public function format(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 52 | + $level = $event->getLevel(); |
|
| 53 | + $message = $event->getRenderedMessage(); |
|
| 54 | + return "$level - $message" . PHP_EOL; |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -29,89 +29,89 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | abstract class Payone_Log4php_LoggerConfigurable { |
| 31 | 31 | |
| 32 | - /** Setter function for boolean type. */ |
|
| 33 | - protected function setBoolean($property, $value) { |
|
| 34 | - try { |
|
| 35 | - $this->$property = Payone_Log4php_LoggerOptionConverter::toBooleanEx($value); |
|
| 36 | - } catch (Exception $ex) { |
|
| 37 | - $value = var_export($value, true); |
|
| 38 | - $this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed."); |
|
| 39 | - } |
|
| 40 | - } |
|
| 32 | + /** Setter function for boolean type. */ |
|
| 33 | + protected function setBoolean($property, $value) { |
|
| 34 | + try { |
|
| 35 | + $this->$property = Payone_Log4php_LoggerOptionConverter::toBooleanEx($value); |
|
| 36 | + } catch (Exception $ex) { |
|
| 37 | + $value = var_export($value, true); |
|
| 38 | + $this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed."); |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** Setter function for integer type. */ |
|
| 43 | - protected function setInteger($property, $value) { |
|
| 44 | - try { |
|
| 45 | - $this->$property = Payone_Log4php_LoggerOptionConverter::toIntegerEx($value); |
|
| 46 | - } catch (Exception $ex) { |
|
| 47 | - $value = var_export($value, true); |
|
| 48 | - $this->warn("Invalid value given for '$property' property: [$value]. Expected an integer. Property not changed."); |
|
| 49 | - } |
|
| 50 | - } |
|
| 42 | + /** Setter function for integer type. */ |
|
| 43 | + protected function setInteger($property, $value) { |
|
| 44 | + try { |
|
| 45 | + $this->$property = Payone_Log4php_LoggerOptionConverter::toIntegerEx($value); |
|
| 46 | + } catch (Exception $ex) { |
|
| 47 | + $value = var_export($value, true); |
|
| 48 | + $this->warn("Invalid value given for '$property' property: [$value]. Expected an integer. Property not changed."); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** Setter function for LoggerLevel values. */ |
|
| 53 | - protected function setLevel($property, $value) { |
|
| 54 | - try { |
|
| 55 | - $this->$property = Payone_Log4php_LoggerOptionConverter::toLevelEx($value); |
|
| 56 | - } catch (Exception $ex) { |
|
| 57 | - $value = var_export($value, true); |
|
| 58 | - $this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed."); |
|
| 59 | - } |
|
| 60 | - } |
|
| 52 | + /** Setter function for LoggerLevel values. */ |
|
| 53 | + protected function setLevel($property, $value) { |
|
| 54 | + try { |
|
| 55 | + $this->$property = Payone_Log4php_LoggerOptionConverter::toLevelEx($value); |
|
| 56 | + } catch (Exception $ex) { |
|
| 57 | + $value = var_export($value, true); |
|
| 58 | + $this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed."); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** Setter function for integer type. */ |
|
| 63 | - protected function setPositiveInteger($property, $value) { |
|
| 64 | - try { |
|
| 65 | - $this->$property = Payone_Log4php_LoggerOptionConverter::toPositiveIntegerEx($value); |
|
| 66 | - } catch (Exception $ex) { |
|
| 67 | - $value = var_export($value, true); |
|
| 68 | - $this->warn("Invalid value given for '$property' property: [$value]. Expected a positive integer. Property not changed."); |
|
| 69 | - } |
|
| 70 | - } |
|
| 62 | + /** Setter function for integer type. */ |
|
| 63 | + protected function setPositiveInteger($property, $value) { |
|
| 64 | + try { |
|
| 65 | + $this->$property = Payone_Log4php_LoggerOptionConverter::toPositiveIntegerEx($value); |
|
| 66 | + } catch (Exception $ex) { |
|
| 67 | + $value = var_export($value, true); |
|
| 68 | + $this->warn("Invalid value given for '$property' property: [$value]. Expected a positive integer. Property not changed."); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** Setter for file size. */ |
|
| 73 | - protected function setFileSize($property, $value) { |
|
| 74 | - try { |
|
| 75 | - $this->$property = Payone_Log4php_LoggerOptionConverter::toFileSizeEx($value); |
|
| 76 | - } catch (Exception $ex) { |
|
| 77 | - $value = var_export($value, true); |
|
| 78 | - $this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed."); |
|
| 79 | - } |
|
| 80 | - } |
|
| 72 | + /** Setter for file size. */ |
|
| 73 | + protected function setFileSize($property, $value) { |
|
| 74 | + try { |
|
| 75 | + $this->$property = Payone_Log4php_LoggerOptionConverter::toFileSizeEx($value); |
|
| 76 | + } catch (Exception $ex) { |
|
| 77 | + $value = var_export($value, true); |
|
| 78 | + $this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed."); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** Setter function for numeric type. */ |
|
| 83 | - protected function setNumeric($property, $value) { |
|
| 84 | - try { |
|
| 85 | - $this->$property = Payone_Log4php_LoggerOptionConverter::toNumericEx($value); |
|
| 86 | - } catch (Exception $ex) { |
|
| 87 | - $value = var_export($value, true); |
|
| 88 | - $this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed."); |
|
| 89 | - } |
|
| 90 | - } |
|
| 82 | + /** Setter function for numeric type. */ |
|
| 83 | + protected function setNumeric($property, $value) { |
|
| 84 | + try { |
|
| 85 | + $this->$property = Payone_Log4php_LoggerOptionConverter::toNumericEx($value); |
|
| 86 | + } catch (Exception $ex) { |
|
| 87 | + $value = var_export($value, true); |
|
| 88 | + $this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed."); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** Setter function for string type. */ |
|
| 93 | - protected function setString($property, $value, $nullable = false) { |
|
| 94 | - if ($value === null) { |
|
| 95 | - if($nullable) { |
|
| 96 | - $this->$property= null; |
|
| 97 | - } else { |
|
| 98 | - $this->warn("Null value given for '$property' property. Expected a string. Property not changed."); |
|
| 99 | - } |
|
| 100 | - } else { |
|
| 101 | - try { |
|
| 102 | - $this->$property = Payone_Log4php_LoggerOptionConverter::toStringEx($value); |
|
| 103 | - } catch (Exception $ex) { |
|
| 104 | - $value = var_export($value, true); |
|
| 105 | - $this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed."); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 92 | + /** Setter function for string type. */ |
|
| 93 | + protected function setString($property, $value, $nullable = false) { |
|
| 94 | + if ($value === null) { |
|
| 95 | + if($nullable) { |
|
| 96 | + $this->$property= null; |
|
| 97 | + } else { |
|
| 98 | + $this->warn("Null value given for '$property' property. Expected a string. Property not changed."); |
|
| 99 | + } |
|
| 100 | + } else { |
|
| 101 | + try { |
|
| 102 | + $this->$property = Payone_Log4php_LoggerOptionConverter::toStringEx($value); |
|
| 103 | + } catch (Exception $ex) { |
|
| 104 | + $value = var_export($value, true); |
|
| 105 | + $this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed."); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** Triggers a warning. */ |
|
| 111 | - protected function warn($message) { |
|
| 112 | - $class = get_class($this); |
|
| 113 | - trigger_error("log4php: $class: $message", E_USER_WARNING); |
|
| 114 | - } |
|
| 110 | + /** Triggers a warning. */ |
|
| 111 | + protected function warn($message) { |
|
| 112 | + $class = get_class($this); |
|
| 113 | + trigger_error("log4php: $class: $message", E_USER_WARNING); |
|
| 114 | + } |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -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 | } |
@@ -29,5 +29,5 @@ |
||
| 29 | 29 | * @subpackage pattern |
| 30 | 30 | */ |
| 31 | 31 | class Payone_Log4php_LoggerPatternConverterSession extends Payone_Log4php_LoggerPatternConverterSuperglobal { |
| 32 | - protected $name = '_SESSION'; |
|
| 32 | + protected $name = '_SESSION'; |
|
| 33 | 33 | } |
@@ -27,11 +27,11 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class Payone_Log4php_LoggerPatternConverterLine extends Payone_Log4php_LoggerPatternConverter { |
| 29 | 29 | |
| 30 | - public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 31 | - return |
|
| 32 | - $event->getLocationInformation()->getClassName() . '.' . |
|
| 33 | - $event->getLocationInformation()->getMethodName() . '(' . |
|
| 34 | - $event->getLocationInformation()->getFileName() . ':' . |
|
| 35 | - $event->getLocationInformation()->getLineNumber() . ')'; |
|
| 36 | - } |
|
| 30 | + public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 31 | + return |
|
| 32 | + $event->getLocationInformation()->getClassName() . '.' . |
|
| 33 | + $event->getLocationInformation()->getMethodName() . '(' . |
|
| 34 | + $event->getLocationInformation()->getFileName() . ':' . |
|
| 35 | + $event->getLocationInformation()->getLineNumber() . ')'; |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -29,86 +29,86 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class Payone_Log4php_LoggerPatternConverterLogger extends Payone_Log4php_LoggerPatternConverter { |
| 31 | 31 | |
| 32 | - /** Length to which to shorten the name. */ |
|
| 33 | - private $length; |
|
| 32 | + /** Length to which to shorten the name. */ |
|
| 33 | + private $length; |
|
| 34 | 34 | |
| 35 | - /** Holds processed logger names. */ |
|
| 36 | - private $cache = array(); |
|
| 35 | + /** Holds processed logger names. */ |
|
| 36 | + private $cache = array(); |
|
| 37 | 37 | |
| 38 | - public function activateOptions() { |
|
| 39 | - // Parse the option (desired output length) |
|
| 40 | - if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) { |
|
| 41 | - $this->length = (integer) $this->option; |
|
| 42 | - } |
|
| 43 | - } |
|
| 38 | + public function activateOptions() { |
|
| 39 | + // Parse the option (desired output length) |
|
| 40 | + if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) { |
|
| 41 | + $this->length = (integer) $this->option; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 46 | - $name = $event->getLoggerName(); |
|
| 45 | + public function convert(Payone_Log4php_LoggerLoggingEvent $event) { |
|
| 46 | + $name = $event->getLoggerName(); |
|
| 47 | 47 | |
| 48 | - if (!isset($this->cache[$name])) { |
|
| 48 | + if (!isset($this->cache[$name])) { |
|
| 49 | 49 | |
| 50 | - // If length is set return shortened logger name |
|
| 51 | - if (isset($this->length)) { |
|
| 52 | - $this->cache[$name] = $this->shorten($name, $this->length); |
|
| 53 | - } |
|
| 50 | + // If length is set return shortened logger name |
|
| 51 | + if (isset($this->length)) { |
|
| 52 | + $this->cache[$name] = $this->shorten($name, $this->length); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // If no length is specified return full logger name |
|
| 56 | - else { |
|
| 57 | - $this->cache[$name] = $name; |
|
| 58 | - } |
|
| 59 | - } |
|
| 55 | + // If no length is specified return full logger name |
|
| 56 | + else { |
|
| 57 | + $this->cache[$name] = $name; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - return $this->cache[$name]; |
|
| 62 | - } |
|
| 61 | + return $this->cache[$name]; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Attempts to shorten the given name to the desired length by trimming |
|
| 66 | - * name fragments. See docs for examples. |
|
| 67 | - */ |
|
| 68 | - private function shorten($name, $length) { |
|
| 64 | + /** |
|
| 65 | + * Attempts to shorten the given name to the desired length by trimming |
|
| 66 | + * name fragments. See docs for examples. |
|
| 67 | + */ |
|
| 68 | + private function shorten($name, $length) { |
|
| 69 | 69 | |
| 70 | - $currentLength = strlen($name); |
|
| 70 | + $currentLength = strlen($name); |
|
| 71 | 71 | |
| 72 | - // Check if any shortening is required |
|
| 73 | - if ($currentLength <= $length) { |
|
| 74 | - return $name; |
|
| 75 | - } |
|
| 72 | + // Check if any shortening is required |
|
| 73 | + if ($currentLength <= $length) { |
|
| 74 | + return $name; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - // Split name into fragments |
|
| 78 | - $name = str_replace('.', '\\', $name); |
|
| 79 | - $name = trim($name, ' \\'); |
|
| 80 | - $fragments = explode('\\', $name); |
|
| 81 | - $count = count($fragments); |
|
| 77 | + // Split name into fragments |
|
| 78 | + $name = str_replace('.', '\\', $name); |
|
| 79 | + $name = trim($name, ' \\'); |
|
| 80 | + $fragments = explode('\\', $name); |
|
| 81 | + $count = count($fragments); |
|
| 82 | 82 | |
| 83 | - // If the name splits to only one fragment, then it cannot be shortened |
|
| 84 | - if ($count == 1) { |
|
| 85 | - return $name; |
|
| 86 | - } |
|
| 83 | + // If the name splits to only one fragment, then it cannot be shortened |
|
| 84 | + if ($count == 1) { |
|
| 85 | + return $name; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - foreach($fragments as $key => &$fragment) { |
|
| 88 | + foreach($fragments as $key => &$fragment) { |
|
| 89 | 89 | |
| 90 | - // Never shorten last fragment |
|
| 91 | - if ($key == $count - 1) { |
|
| 92 | - break; |
|
| 93 | - } |
|
| 90 | + // Never shorten last fragment |
|
| 91 | + if ($key == $count - 1) { |
|
| 92 | + break; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - // Check for empty fragments (shouldn't happen but it's possible) |
|
| 96 | - $fragLen = strlen($fragment); |
|
| 97 | - if ($fragLen <= 1) { |
|
| 98 | - continue; |
|
| 99 | - } |
|
| 95 | + // Check for empty fragments (shouldn't happen but it's possible) |
|
| 96 | + $fragLen = strlen($fragment); |
|
| 97 | + if ($fragLen <= 1) { |
|
| 98 | + continue; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - // Shorten fragment to one character and check if total length satisfactory |
|
| 102 | - $fragment = substr($fragment, 0, 1); |
|
| 103 | - $currentLength = $currentLength - $fragLen + 1; |
|
| 101 | + // Shorten fragment to one character and check if total length satisfactory |
|
| 102 | + $fragment = substr($fragment, 0, 1); |
|
| 103 | + $currentLength = $currentLength - $fragLen + 1; |
|
| 104 | 104 | |
| 105 | - if ($currentLength <= $length) { |
|
| 106 | - break; |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - unset($fragment); |
|
| 105 | + if ($currentLength <= $length) { |
|
| 106 | + break; |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + unset($fragment); |
|
| 110 | 110 | |
| 111 | - return implode('\\', $fragments); |
|
| 112 | - } |
|
| 111 | + return implode('\\', $fragments); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | 114 | } |
@@ -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) { |
@@ -51,35 +51,35 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | class Payone_Log4php_LoggerConfigurationAdapterPHP implements Payone_Log4php_LoggerConfigurationAdapter |
| 53 | 53 | { |
| 54 | - public function convert($url) { |
|
| 55 | - if (!file_exists($url)) { |
|
| 56 | - throw new Payone_Log4php_LoggerException("File [$url] does not exist."); |
|
| 57 | - } |
|
| 54 | + public function convert($url) { |
|
| 55 | + if (!file_exists($url)) { |
|
| 56 | + throw new Payone_Log4php_LoggerException("File [$url] does not exist."); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - // Load the config file |
|
| 60 | - $data = @file_get_contents($url); |
|
| 61 | - if ($data === false) { |
|
| 62 | - $error = error_get_last(); |
|
| 63 | - throw new Payone_Log4php_LoggerException("Error loading config file: {$error['message']}"); |
|
| 64 | - } |
|
| 59 | + // Load the config file |
|
| 60 | + $data = @file_get_contents($url); |
|
| 61 | + if ($data === false) { |
|
| 62 | + $error = error_get_last(); |
|
| 63 | + throw new Payone_Log4php_LoggerException("Error loading config file: {$error['message']}"); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $config = @eval('?>' . $data); |
|
| 66 | + $config = @eval('?>' . $data); |
|
| 67 | 67 | |
| 68 | - if ($config === false) { |
|
| 69 | - $error = error_get_last(); |
|
| 70 | - throw new Payone_Log4php_LoggerException("Error parsing configuration: " . $error['message']); |
|
| 71 | - } |
|
| 68 | + if ($config === false) { |
|
| 69 | + $error = error_get_last(); |
|
| 70 | + throw new Payone_Log4php_LoggerException("Error parsing configuration: " . $error['message']); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if (empty($config)) { |
|
| 74 | - throw new Payone_Log4php_LoggerException("Invalid configuration: empty configuration array."); |
|
| 75 | - } |
|
| 73 | + if (empty($config)) { |
|
| 74 | + throw new Payone_Log4php_LoggerException("Invalid configuration: empty configuration array."); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - if (!is_array($config)) { |
|
| 78 | - throw new Payone_Log4php_LoggerException("Invalid configuration: not an array."); |
|
| 79 | - } |
|
| 77 | + if (!is_array($config)) { |
|
| 78 | + throw new Payone_Log4php_LoggerException("Invalid configuration: not an array."); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - return $config; |
|
| 82 | - } |
|
| 81 | + return $config; |
|
| 82 | + } |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | ?> |
| 86 | 86 | \ No newline at end of file |