Passed
Push — 1.10.x ( f9cbcd...83c791 )
by Yannick
657:30 queued 614:41
created
main/inc/lib/phpdocx/lib/log4php/LoggerAppender.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
 	/**
210 210
 	 * Set the threshold level of this appender.
211 211
 	 *
212
-	 * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
212
+	 * @param LoggerLevel $threshold can be a {@link LoggerLevel} object or a string.
213 213
 	 * @see LoggerOptionConverter::toLevel()
214 214
 	 */
215 215
 	public function setThreshold($threshold) {
Please login to merge, or discard this patch.
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * Abstract class that defines output logs strategies.
@@ -26,236 +26,236 @@  discard block
 block discarded – undo
26 26
  */
27 27
 abstract class LoggerAppender {
28 28
 	
29
-	/**
30
-	 * @var boolean closed appender flag
31
-	 */
32
-	protected $closed = false;
29
+    /**
30
+     * @var boolean closed appender flag
31
+     */
32
+    protected $closed = false;
33 33
 	
34
-	/**
35
-	 * The first filter in the filter chain
36
-	 * @var LoggerFilter
37
-	 */
38
-	protected $filter = null;
34
+    /**
35
+     * The first filter in the filter chain
36
+     * @var LoggerFilter
37
+     */
38
+    protected $filter = null;
39 39
 			
40
-	/**
41
-	 * LoggerLayout for this appender. It can be null if appender has its own layout
42
-	 * @var LoggerLayout
43
-	 */
44
-	protected $layout = null; 
40
+    /**
41
+     * LoggerLayout for this appender. It can be null if appender has its own layout
42
+     * @var LoggerLayout
43
+     */
44
+    protected $layout = null; 
45 45
 		   
46
-	/**
47
-	 * @var string Appender name
48
-	 */
49
-	protected $name;
46
+    /**
47
+     * @var string Appender name
48
+     */
49
+    protected $name;
50 50
 		   
51
-	/**
52
-	 * @var LoggerLevel There is no level threshold filtering by default.
53
-	 */
54
-	protected $threshold = null;
51
+    /**
52
+     * @var LoggerLevel There is no level threshold filtering by default.
53
+     */
54
+    protected $threshold = null;
55 55
 	
56
-	/**
57
-	 * @var boolean needs a layout formatting ?
58
-	 */
59
-	protected $requiresLayout = false;
56
+    /**
57
+     * @var boolean needs a layout formatting ?
58
+     */
59
+    protected $requiresLayout = false;
60 60
 	
61
-	/**
62
-	 * Constructor
63
-	 *
64
-	 * @param string $name appender name
65
-	 */
66
-	public function __construct($name = '') {
67
-		$this->name = $name;
68
-	}
61
+    /**
62
+     * Constructor
63
+     *
64
+     * @param string $name appender name
65
+     */
66
+    public function __construct($name = '') {
67
+        $this->name = $name;
68
+    }
69 69
 
70
-	/**
71
-	 * Add a filter to the end of the filter list.
72
-	 *
73
-	 * @param LoggerFilter $newFilter add a new LoggerFilter
74
-	 */
75
-	public function addFilter($newFilter) {
76
-		if($this->filter === null) {
77
-			$this->filter = $newFilter;
78
-		} else {
79
-			$this->filter->addNext($newFilter);
80
-		}
81
-	}
70
+    /**
71
+     * Add a filter to the end of the filter list.
72
+     *
73
+     * @param LoggerFilter $newFilter add a new LoggerFilter
74
+     */
75
+    public function addFilter($newFilter) {
76
+        if($this->filter === null) {
77
+            $this->filter = $newFilter;
78
+        } else {
79
+            $this->filter->addNext($newFilter);
80
+        }
81
+    }
82 82
 	
83
-	/**
84
-	 * Clear the list of filters by removing all the filters in it.
85
-	 * @abstract
86
-	 */
87
-	public function clearFilters() {
88
-		unset($this->filter);
89
-		$this->filter = null;
90
-	}
83
+    /**
84
+     * Clear the list of filters by removing all the filters in it.
85
+     * @abstract
86
+     */
87
+    public function clearFilters() {
88
+        unset($this->filter);
89
+        $this->filter = null;
90
+    }
91 91
 
92
-	/**
93
-	 * Return the first filter in the filter chain for this Appender. 
94
-	 * The return value may be <i>null</i> if no is filter is set.
95
-	 * @return LoggerFilter
96
-	 */
97
-	public function getFilter() {
98
-		return $this->filter;
99
-	} 
92
+    /**
93
+     * Return the first filter in the filter chain for this Appender. 
94
+     * The return value may be <i>null</i> if no is filter is set.
95
+     * @return LoggerFilter
96
+     */
97
+    public function getFilter() {
98
+        return $this->filter;
99
+    } 
100 100
 	
101
-	/** 
102
-	 * Return the first filter in the filter chain for this Appender. 
103
-	 * The return value may be <i>null</i> if no is filter is set.
104
-	 * @return LoggerFilter
105
-	 */
106
-	public function getFirstFilter() {
107
-		return $this->filter;
108
-	}
101
+    /** 
102
+     * Return the first filter in the filter chain for this Appender. 
103
+     * The return value may be <i>null</i> if no is filter is set.
104
+     * @return LoggerFilter
105
+     */
106
+    public function getFirstFilter() {
107
+        return $this->filter;
108
+    }
109 109
 	
110 110
 	
111
-	/**
112
-	 * This method performs threshold checks and invokes filters before
113
-	 * delegating actual logging to the subclasses specific <i>append()</i> method.
114
-	 * @see LoggerAppender::doAppend()
115
-	 * @param LoggerLoggingEvent $event
116
-	 */
117
-	public function doAppend(LoggerLoggingEvent $event) {
118
-		if($this->closed) {
119
-			return;
120
-		}
111
+    /**
112
+     * This method performs threshold checks and invokes filters before
113
+     * delegating actual logging to the subclasses specific <i>append()</i> method.
114
+     * @see LoggerAppender::doAppend()
115
+     * @param LoggerLoggingEvent $event
116
+     */
117
+    public function doAppend(LoggerLoggingEvent $event) {
118
+        if($this->closed) {
119
+            return;
120
+        }
121 121
 		
122
-		if(!$this->isAsSevereAsThreshold($event->getLevel())) {
123
-			return;
124
-		}
122
+        if(!$this->isAsSevereAsThreshold($event->getLevel())) {
123
+            return;
124
+        }
125 125
 
126
-		$f = $this->getFirstFilter();
127
-		while($f !== null) {
128
-			switch ($f->decide($event)) {
129
-				case LoggerFilter::DENY: return;
130
-				case LoggerFilter::ACCEPT: return $this->append($event);
131
-				case LoggerFilter::NEUTRAL: $f = $f->getNext();
132
-			}
133
-		}
134
-		$this->append($event);	  
135
-	}	 
126
+        $f = $this->getFirstFilter();
127
+        while($f !== null) {
128
+            switch ($f->decide($event)) {
129
+                case LoggerFilter::DENY: return;
130
+                case LoggerFilter::ACCEPT: return $this->append($event);
131
+                case LoggerFilter::NEUTRAL: $f = $f->getNext();
132
+            }
133
+        }
134
+        $this->append($event);	  
135
+    }	 
136 136
 
137
-	/**
138
-	 * Set the Layout for this appender.
139
-	 * @see LoggerAppender::setLayout()
140
-	 * @param LoggerLayout $layout
141
-	 */
142
-	public function setLayout($layout) {
143
-		if($this->requiresLayout()) {
144
-			$this->layout = $layout;
145
-		}
146
-	} 
137
+    /**
138
+     * Set the Layout for this appender.
139
+     * @see LoggerAppender::setLayout()
140
+     * @param LoggerLayout $layout
141
+     */
142
+    public function setLayout($layout) {
143
+        if($this->requiresLayout()) {
144
+            $this->layout = $layout;
145
+        }
146
+    } 
147 147
 	
148
-	/**
149
-	 * Returns this appender layout.
150
-	 * @see LoggerAppender::getLayout()
151
-	 * @return LoggerLayout
152
-	 */
153
-	public function getLayout() {
154
-		return $this->layout;
155
-	}
148
+    /**
149
+     * Returns this appender layout.
150
+     * @see LoggerAppender::getLayout()
151
+     * @return LoggerLayout
152
+     */
153
+    public function getLayout() {
154
+        return $this->layout;
155
+    }
156 156
 	
157
-	/**
158
-	 * Configurators call this method to determine if the appender
159
-	 * requires a layout. 
160
-	 *
161
-	 * <p>If this method returns <i>true</i>, meaning that layout is required, 
162
-	 * then the configurator will configure a layout using the configuration 
163
-	 * information at its disposal.	 If this method returns <i>false</i>, 
164
-	 * meaning that a layout is not required, then layout configuration will be
165
-	 * skipped even if there is available layout configuration
166
-	 * information at the disposal of the configurator.</p>
167
-	 *
168
-	 * <p>In the rather exceptional case, where the appender
169
-	 * implementation admits a layout but can also work without it, then
170
-	 * the appender should return <i>true</i>.</p>
171
-	 * 
172
-	 * @see LoggerAppender::requiresLayout()
173
-	 * @return boolean
174
-	 */
175
-	public function requiresLayout() {
176
-		return $this->requiresLayout;
177
-	}
157
+    /**
158
+     * Configurators call this method to determine if the appender
159
+     * requires a layout. 
160
+     *
161
+     * <p>If this method returns <i>true</i>, meaning that layout is required, 
162
+     * then the configurator will configure a layout using the configuration 
163
+     * information at its disposal.	 If this method returns <i>false</i>, 
164
+     * meaning that a layout is not required, then layout configuration will be
165
+     * skipped even if there is available layout configuration
166
+     * information at the disposal of the configurator.</p>
167
+     *
168
+     * <p>In the rather exceptional case, where the appender
169
+     * implementation admits a layout but can also work without it, then
170
+     * the appender should return <i>true</i>.</p>
171
+     * 
172
+     * @see LoggerAppender::requiresLayout()
173
+     * @return boolean
174
+     */
175
+    public function requiresLayout() {
176
+        return $this->requiresLayout;
177
+    }
178 178
 	
179
-	/**
180
-	 * Get the name of this appender.
181
-	 * @see LoggerAppender::getName()
182
-	 * @return string
183
-	 */
184
-	public function getName() {
185
-		return $this->name;
186
-	}
179
+    /**
180
+     * Get the name of this appender.
181
+     * @see LoggerAppender::getName()
182
+     * @return string
183
+     */
184
+    public function getName() {
185
+        return $this->name;
186
+    }
187 187
 	
188 188
 /**
189
-	 * Set the name of this appender.
190
-	 *
191
-	 * The name is used by other components to identify this appender.
192
-	 *
193
-	 * 
194
-	 * @param string $name
195
-	 */
196
-	public function setName($name) {
197
-		$this->name = $name;	
198
-	}
189
+ * Set the name of this appender.
190
+ *
191
+ * The name is used by other components to identify this appender.
192
+ *
193
+ * 
194
+ * @param string $name
195
+ */
196
+    public function setName($name) {
197
+        $this->name = $name;	
198
+    }
199 199
 	
200
-	/**
201
-	 * Returns this appenders threshold level. 
202
-	 * See the {@link setThreshold()} method for the meaning of this option.
203
-	 * @return LoggerLevel
204
-	 */
205
-	public function getThreshold() { 
206
-		return $this->threshold;
207
-	}
200
+    /**
201
+     * Returns this appenders threshold level. 
202
+     * See the {@link setThreshold()} method for the meaning of this option.
203
+     * @return LoggerLevel
204
+     */
205
+    public function getThreshold() { 
206
+        return $this->threshold;
207
+    }
208 208
 	
209
-	/**
210
-	 * Set the threshold level of this appender.
211
-	 *
212
-	 * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
213
-	 * @see LoggerOptionConverter::toLevel()
214
-	 */
215
-	public function setThreshold($threshold) {
216
-		if(is_string($threshold)) {
217
-		   $this->threshold = LoggerOptionConverter::toLevel($threshold, null);
218
-		} else if($threshold instanceof LoggerLevel) {
219
-		   $this->threshold = $threshold;
220
-		}
221
-	}
209
+    /**
210
+     * Set the threshold level of this appender.
211
+     *
212
+     * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
213
+     * @see LoggerOptionConverter::toLevel()
214
+     */
215
+    public function setThreshold($threshold) {
216
+        if(is_string($threshold)) {
217
+            $this->threshold = LoggerOptionConverter::toLevel($threshold, null);
218
+        } else if($threshold instanceof LoggerLevel) {
219
+            $this->threshold = $threshold;
220
+        }
221
+    }
222 222
 	
223
-	/**
224
-	 * Check whether the message level is below the appender's threshold. 
225
-	 *
226
-	 *
227
-	 * If there is no threshold set, then the return value is always <i>true</i>.
228
-	 * @param LoggerLevel $level
229
-	 * @return boolean true if priority is greater or equal than threshold	
230
-	 */
231
-	public function isAsSevereAsThreshold($level) {
232
-		if($this->threshold === null) {
233
-			return true;
234
-		}
235
-		return $level->isGreaterOrEqual($this->getThreshold());
236
-	}
223
+    /**
224
+     * Check whether the message level is below the appender's threshold. 
225
+     *
226
+     *
227
+     * If there is no threshold set, then the return value is always <i>true</i>.
228
+     * @param LoggerLevel $level
229
+     * @return boolean true if priority is greater or equal than threshold	
230
+     */
231
+    public function isAsSevereAsThreshold($level) {
232
+        if($this->threshold === null) {
233
+            return true;
234
+        }
235
+        return $level->isGreaterOrEqual($this->getThreshold());
236
+    }
237 237
 
238
-	/**
239
-	 * Derived appenders should override this method if option structure
240
-	 * requires it.
241
-	 */
242
-	abstract public function activateOptions();	   
238
+    /**
239
+     * Derived appenders should override this method if option structure
240
+     * requires it.
241
+     */
242
+    abstract public function activateOptions();	   
243 243
 	
244
-	/**
245
-	 * Subclasses of {@link LoggerAppender} should implement 
246
-	 * this method to perform actual logging.
247
-	 *
248
-	 * @param LoggerLoggingEvent $event
249
-	 * @see doAppend()
250
-	 * @abstract
251
-	 */
252
-	abstract protected function append(LoggerLoggingEvent $event); 
244
+    /**
245
+     * Subclasses of {@link LoggerAppender} should implement 
246
+     * this method to perform actual logging.
247
+     *
248
+     * @param LoggerLoggingEvent $event
249
+     * @see doAppend()
250
+     * @abstract
251
+     */
252
+    abstract protected function append(LoggerLoggingEvent $event); 
253 253
 
254
-	/**
255
-	 * Release any resources allocated.
256
-	 * Subclasses of {@link LoggerAppender} should implement 
257
-	 * this method to perform proper closing procedures.
258
-	 * @abstract
259
-	 */
260
-	abstract public function close();
254
+    /**
255
+     * Release any resources allocated.
256
+     * Subclasses of {@link LoggerAppender} should implement 
257
+     * this method to perform proper closing procedures.
258
+     * @abstract
259
+     */
260
+    abstract public function close();
261 261
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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());
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerHierarchy.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	
72 72
 	/**
73 73
 	 * Create a new logger hierarchy.
74
-	 * @param object $root the root logger
74
+	 * @param LoggerRoot $root the root logger
75 75
 	 */
76 76
 	public function __construct(LoggerRoot $root) {
77 77
 		$this->root = $root;
@@ -107,7 +107,6 @@  discard block
 block discarded – undo
107 107
 	 * Return a new logger instance named as the first parameter using the default factory.
108 108
 	 * 
109 109
 	 * @param string $name logger name
110
-	 * @param LoggerFactory $factory a {@link LoggerFactory} instance or null	  
111 110
 	 * @return Logger
112 111
 	 */
113 112
 	public function getLogger($name) {
Please login to merge, or discard this patch.
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * This class is specialized in retrieving loggers by name and also maintaining 
@@ -47,199 +47,199 @@  discard block
 block discarded – undo
47 47
  * @version $Revision: 822448 $
48 48
  * @package log4php
49 49
  */
50
- /*
50
+    /*
51 51
   * TODO:
52 52
   * - addHierarchyEventListener($listener) not supported
53 53
   * - emitNoAppenderWarning($cat) not supported
54 54
   * - fireAddAppenderEvent not supported
55 55
   */
56 56
 class LoggerHierarchy {
57
-	/** Default Factory  */
58
-	protected $defaultFactory;
57
+    /** Default Factory  */
58
+    protected $defaultFactory;
59 59
 	
60
-	/** array hierarchy tree. saves here all loggers */
61
-	protected $ht = array();
60
+    /** array hierarchy tree. saves here all loggers */
61
+    protected $ht = array();
62 62
 	
63
-	/** The root Logger */
64
-	protected $root = null;
63
+    /** The root Logger */
64
+    protected $root = null;
65 65
 	
66
-	/** LoggerRendererMap */
67
-	protected $rendererMap;
66
+    /** LoggerRendererMap */
67
+    protected $rendererMap;
68 68
 
69
-	/** LoggerLevel main level threshold */
70
-	protected $threshold;
69
+    /** LoggerLevel main level threshold */
70
+    protected $threshold;
71 71
 	
72
-	/**
73
-	 * Create a new logger hierarchy.
74
-	 * @param object $root the root logger
75
-	 */
76
-	public function __construct(LoggerRoot $root) {
77
-		$this->root = $root;
78
-		$this->setThreshold(LoggerLevel::getLevelAll());
79
-		$this->rendererMap = new LoggerRendererMap();
80
-	}
72
+    /**
73
+     * Create a new logger hierarchy.
74
+     * @param object $root the root logger
75
+     */
76
+    public function __construct(LoggerRoot $root) {
77
+        $this->root = $root;
78
+        $this->setThreshold(LoggerLevel::getLevelAll());
79
+        $this->rendererMap = new LoggerRendererMap();
80
+    }
81 81
 	 
82
-	/**
83
-	 * This call will clear all logger definitions from the internal hashtable.
84
-	 */
85
-	public function clear() {
86
-		$this->ht = array();
87
-	}
82
+    /**
83
+     * This call will clear all logger definitions from the internal hashtable.
84
+     */
85
+    public function clear() {
86
+        $this->ht = array();
87
+    }
88 88
 	  
89
-	/**
90
-	 * Check if the named logger exists in the hierarchy.
91
-	 * @param string $name
92
-	 * @return boolean
93
-	 */
94
-	public function exists($name) {
95
-		return isset($this->ht[$name]);
96
-	}
89
+    /**
90
+     * Check if the named logger exists in the hierarchy.
91
+     * @param string $name
92
+     * @return boolean
93
+     */
94
+    public function exists($name) {
95
+        return isset($this->ht[$name]);
96
+    }
97 97
 
98
-	/**
99
-	 * Returns all the currently defined categories in this hierarchy as an array.
100
-	 * @return array
101
-	 */	 
102
-	public function getCurrentLoggers() {
103
-		return array_values($this->ht);
104
-	}
98
+    /**
99
+     * Returns all the currently defined categories in this hierarchy as an array.
100
+     * @return array
101
+     */	 
102
+    public function getCurrentLoggers() {
103
+        return array_values($this->ht);
104
+    }
105 105
 	
106
-	/**
107
-	 * Return a new logger instance named as the first parameter using the default factory.
108
-	 * 
109
-	 * @param string $name logger name
110
-	 * @param LoggerFactory $factory a {@link LoggerFactory} instance or null	  
111
-	 * @return Logger
112
-	 */
113
-	public function getLogger($name) {
114
-		if(!isset($this->ht[$name])) {
115
-			$this->ht[$name] = new Logger($name);;
116
-			// TODO: isn't necessary, access via singleton?
117
-			// $this->ht[$name]->setHierarchy($this);
118
-			$nodes = explode('.', $name);
119
-			$firstNode = array_shift($nodes);
106
+    /**
107
+     * Return a new logger instance named as the first parameter using the default factory.
108
+     * 
109
+     * @param string $name logger name
110
+     * @param LoggerFactory $factory a {@link LoggerFactory} instance or null	  
111
+     * @return Logger
112
+     */
113
+    public function getLogger($name) {
114
+        if(!isset($this->ht[$name])) {
115
+            $this->ht[$name] = new Logger($name);;
116
+            // TODO: isn't necessary, access via singleton?
117
+            // $this->ht[$name]->setHierarchy($this);
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->ht[$firstNode])) {
123
-				$this->ht[$name]->setParent($this->ht[$firstNode]);
124
-			} else {
125
-				// if there is no father, set root logger as father
126
-				$this->ht[$name]->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->ht[$firstNode])) {
123
+                $this->ht[$name]->setParent($this->ht[$firstNode]);
124
+            } else {
125
+                // if there is no father, set root logger as father
126
+                $this->ht[$name]->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->ht[$parentNode]) and $parentNode != $name) {
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->ht[$parentNode]) and $parentNode != $name) {
135 135
 		
136
-						$this->ht[$name]->setParent($this->ht[$parentNode]);
137
-					}
138
-					$firstNode .= ".$node";
139
-				}
140
-			}
141
-		}		
136
+                        $this->ht[$name]->setParent($this->ht[$parentNode]);
137
+                    }
138
+                    $firstNode .= ".$node";
139
+                }
140
+            }
141
+        }		
142 142
 		
143
-		return $this->ht[$name];
144
-	} 
143
+        return $this->ht[$name];
144
+    } 
145 145
 	
146
-	/**
147
-	 * @return LoggerRendererMap Get the renderer map for this hierarchy.
148
-	 */
149
-	public function getRendererMap() {
150
-		return $this->rendererMap;
151
-	}
146
+    /**
147
+     * @return LoggerRendererMap Get the renderer map for this hierarchy.
148
+     */
149
+    public function getRendererMap() {
150
+        return $this->rendererMap;
151
+    }
152 152
 	
153
-	/**
154
-	 * @return LoggerRoot Get the root of this hierarchy.
155
-	 */ 
156
-	public function getRootLogger() {
157
-		if(!isset($this->root) or $this->root == null) {
158
-			$this->root = new LoggerRoot();
159
-		}
160
-		return $this->root;
161
-	}
153
+    /**
154
+     * @return LoggerRoot Get the root of this hierarchy.
155
+     */ 
156
+    public function getRootLogger() {
157
+        if(!isset($this->root) or $this->root == null) {
158
+            $this->root = new LoggerRoot();
159
+        }
160
+        return $this->root;
161
+    }
162 162
 	 
163
-	/**
164
-	 * @return LoggerLevel Returns the threshold Level.
165
-	 */
166
-	public function getThreshold() {
167
-		return $this->threshold;
168
-	} 
163
+    /**
164
+     * @return LoggerLevel Returns the threshold Level.
165
+     */
166
+    public function getThreshold() {
167
+        return $this->threshold;
168
+    } 
169 169
 
170
-	/**
171
-	 * This method will return true if this repository is disabled 
172
-	 * for level object passed as parameter and false otherwise.
173
-	 * @return boolean
174
-	 */
175
-	public function isDisabled(LoggerLevel $level) {
176
-		return ($this->threshold->toInt() > $level->toInt());
177
-	}
170
+    /**
171
+     * This method will return true if this repository is disabled 
172
+     * for level object passed as parameter and false otherwise.
173
+     * @return boolean
174
+     */
175
+    public function isDisabled(LoggerLevel $level) {
176
+        return ($this->threshold->toInt() > $level->toInt());
177
+    }
178 178
 	
179
-	/**
180
-	 * Reset all values contained in this hierarchy instance to their
181
-	 * default. 
182
-	 *
183
-	 * This removes all appenders from all categories, sets
184
-	 * the level of all non-root categories to <i>null</i>,
185
-	 * sets their additivity flag to <i>true</i> and sets the level
186
-	 * of the root logger to {@link LOGGER_LEVEL_DEBUG}.  Moreover,
187
-	 * message disabling is set its default "off" value.
188
-	 * 
189
-	 * <p>Existing categories are not removed. They are just reset.
190
-	 *
191
-	 * <p>This method should be used sparingly and with care as it will
192
-	 * block all logging until it is completed.</p>
193
-	 */
194
-	public function resetConfiguration() {
195
-		$root = $this->getRootLogger();
179
+    /**
180
+     * Reset all values contained in this hierarchy instance to their
181
+     * default. 
182
+     *
183
+     * This removes all appenders from all categories, sets
184
+     * the level of all non-root categories to <i>null</i>,
185
+     * sets their additivity flag to <i>true</i> and sets the level
186
+     * of the root logger to {@link LOGGER_LEVEL_DEBUG}.  Moreover,
187
+     * message disabling is set its default "off" value.
188
+     * 
189
+     * <p>Existing categories are not removed. They are just reset.
190
+     *
191
+     * <p>This method should be used sparingly and with care as it will
192
+     * block all logging until it is completed.</p>
193
+     */
194
+    public function resetConfiguration() {
195
+        $root = $this->getRootLogger();
196 196
 		
197
-		$root->setLevel(LoggerLevel::getLevelDebug());
198
-		$this->setThreshold(LoggerLevel::getLevelAll());
199
-		$this->shutDown();
200
-		$loggers = $this->getCurrentLoggers();
201
-		$enumLoggers = count($loggers);
202
-		for($i = 0; $i < $enumLoggers; $i++) {
203
-			$loggers[$i]->setLevel(null);
204
-			$loggers[$i]->setAdditivity(true);
205
-			$loggers[$i]->removeAllAppenders();
206
-		}
207
-		$this->rendererMap->clear();
208
-	}
197
+        $root->setLevel(LoggerLevel::getLevelDebug());
198
+        $this->setThreshold(LoggerLevel::getLevelAll());
199
+        $this->shutDown();
200
+        $loggers = $this->getCurrentLoggers();
201
+        $enumLoggers = count($loggers);
202
+        for($i = 0; $i < $enumLoggers; $i++) {
203
+            $loggers[$i]->setLevel(null);
204
+            $loggers[$i]->setAdditivity(true);
205
+            $loggers[$i]->removeAllAppenders();
206
+        }
207
+        $this->rendererMap->clear();
208
+    }
209 209
 	
210
-	/**
211
-	 * set a new threshold level
212
-	 *
213
-	 * @param LoggerLevel $l
214
-	 */
215
-	public function setThreshold(LoggerLevel $l) {
216
-		if($l !== null) {
217
-			$this->threshold = $l;
218
-		}
219
-	}
210
+    /**
211
+     * set a new threshold level
212
+     *
213
+     * @param LoggerLevel $l
214
+     */
215
+    public function setThreshold(LoggerLevel $l) {
216
+        if($l !== null) {
217
+            $this->threshold = $l;
218
+        }
219
+    }
220 220
 	
221
-	/**
222
-	 * Shutting down a hierarchy will <i>safely</i> close and remove
223
-	 * all appenders in all categories including the root logger.
224
-	 * 
225
-	 * <p>Some appenders such as {@link LoggerSocketAppender}
226
-	 * need to be closed before the
227
-	 * application exists. Otherwise, pending logging events might be
228
-	 * lost.
229
-	 * 
230
-	 * <p>The shutdown method is careful to close nested
231
-	 * appenders before closing regular appenders. This is allows
232
-	 * configurations where a regular appender is attached to a logger
233
-	 * and again to a nested appender.
234
-	 */
235
-	public function shutdown() {
236
-		$this->root->removeAllAppenders();
237
-		$cats = $this->getCurrentLoggers();
238
-		$enumCats = count($cats);		  
239
-		if($enumCats > 0) {
240
-			for($i = 0; $i < $enumCats; $i++) {
241
-				$cats[$i]->removeAllAppenders();
242
-			}
243
-		}
244
-	}
221
+    /**
222
+     * Shutting down a hierarchy will <i>safely</i> close and remove
223
+     * all appenders in all categories including the root logger.
224
+     * 
225
+     * <p>Some appenders such as {@link LoggerSocketAppender}
226
+     * need to be closed before the
227
+     * application exists. Otherwise, pending logging events might be
228
+     * lost.
229
+     * 
230
+     * <p>The shutdown method is careful to close nested
231
+     * appenders before closing regular appenders. This is allows
232
+     * configurations where a regular appender is attached to a logger
233
+     * and again to a nested appender.
234
+     */
235
+    public function shutdown() {
236
+        $this->root->removeAllAppenders();
237
+        $cats = $this->getCurrentLoggers();
238
+        $enumCats = count($cats);		  
239
+        if($enumCats > 0) {
240
+            for($i = 0; $i < $enumCats; $i++) {
241
+                $cats[$i]->removeAllAppenders();
242
+            }
243
+        }
244
+    }
245 245
 } 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 	 * @return Logger
112 112
 	 */
113 113
 	public function getLogger($name) {
114
-		if(!isset($this->ht[$name])) {
115
-			$this->ht[$name] = new Logger($name);;
114
+		if (!isset($this->ht[$name])) {
115
+			$this->ht[$name] = new Logger($name); ;
116 116
 			// TODO: isn't necessary, access via singleton?
117 117
 			// $this->ht[$name]->setHierarchy($this);
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->ht[$firstNode])) {
122
+			if ($firstNode != $name and isset($this->ht[$firstNode])) {
123 123
 				$this->ht[$name]->setParent($this->ht[$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->ht[$parentNode]) and $parentNode != $name) {
134
+					if (isset($this->ht[$parentNode]) and $parentNode != $name) {
135 135
 		
136 136
 						$this->ht[$name]->setParent($this->ht[$parentNode]);
137 137
 					}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @return LoggerRoot Get the root of this hierarchy.
155 155
 	 */ 
156 156
 	public function getRootLogger() {
157
-		if(!isset($this->root) or $this->root == null) {
157
+		if (!isset($this->root) or $this->root == null) {
158 158
 			$this->root = new LoggerRoot();
159 159
 		}
160 160
 		return $this->root;
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 		$this->shutDown();
200 200
 		$loggers = $this->getCurrentLoggers();
201 201
 		$enumLoggers = count($loggers);
202
-		for($i = 0; $i < $enumLoggers; $i++) {
202
+		for ($i = 0; $i < $enumLoggers; $i++) {
203 203
 			$loggers[$i]->setLevel(null);
204 204
 			$loggers[$i]->setAdditivity(true);
205 205
 			$loggers[$i]->removeAllAppenders();
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	 * @param LoggerLevel $l
214 214
 	 */
215 215
 	public function setThreshold(LoggerLevel $l) {
216
-		if($l !== null) {
216
+		if ($l !== null) {
217 217
 			$this->threshold = $l;
218 218
 		}
219 219
 	}
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 		$this->root->removeAllAppenders();
237 237
 		$cats = $this->getCurrentLoggers();
238 238
 		$enumCats = count($cats);		  
239
-		if($enumCats > 0) {
240
-			for($i = 0; $i < $enumCats; $i++) {
239
+		if ($enumCats > 0) {
240
+			for ($i = 0; $i < $enumCats; $i++) {
241 241
 				$cats[$i]->removeAllAppenders();
242 242
 			}
243 243
 		}
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerLevel.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	/**
79 79
 	 * Two priorities are equal if their level fields are equal.
80 80
 	 *
81
-	 * @param object $o
82
-	 * @return boolean 
81
+	 * @param LoggerLevel $o
82
+	 * @return boolean|null 
83 83
 	 */
84 84
 	public function equals($o) {
85 85
 		if($o instanceof LoggerLevel) {
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 * Convert the string passed as argument to a level. If the
221 221
 	 * conversion fails, then this method returns a DEBUG Level.
222 222
 	 *
223
-	 * @param mixed $arg
224
-	 * @param LoggerLevel $default
223
+	 * @param string $arg
224
+	 * @param LoggerLevel $defaultLevel
225 225
 	 * @static 
226 226
 	 */
227 227
 	public static function toLevel($arg, $defaultLevel = null) {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	 * @return boolean 
83 83
 	 */
84 84
 	public function equals($o) {
85
-		if($o instanceof LoggerLevel) {
86
-			if($this->level == $o->level) {
85
+		if ($o instanceof LoggerLevel) {
86
+			if ($this->level == $o->level) {
87 87
 			    return true;
88 88
 			}
89 89
 		} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @return LoggerLevel
98 98
 	 */
99 99
 	public static function getLevelOff() {
100
-		if(!isset(self::$levelMap[LoggerLevel::OFF])) {
100
+		if (!isset(self::$levelMap[LoggerLevel::OFF])) {
101 101
 			self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0);
102 102
 		}
103 103
 		return self::$levelMap[LoggerLevel::OFF];
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return LoggerLevel
110 110
 	 */
111 111
 	public static function getLevelFatal() {
112
-		if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
112
+		if (!isset(self::$levelMap[LoggerLevel::FATAL])) {
113 113
 			self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0);
114 114
 		}
115 115
 		return self::$levelMap[LoggerLevel::FATAL];
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return LoggerLevel
122 122
 	 */
123 123
 	public static function getLevelError() {
124
-		if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
124
+		if (!isset(self::$levelMap[LoggerLevel::ERROR])) {
125 125
 			self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3);
126 126
 		}
127 127
 		return self::$levelMap[LoggerLevel::ERROR];
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @return LoggerLevel
134 134
 	 */
135 135
 	public static function getLevelWarn() {
136
-		if(!isset(self::$levelMap[LoggerLevel::WARN])) {
136
+		if (!isset(self::$levelMap[LoggerLevel::WARN])) {
137 137
 			self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4);
138 138
 		}
139 139
 		return self::$levelMap[LoggerLevel::WARN];
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return LoggerLevel
146 146
 	 */
147 147
 	public static function getLevelInfo() {
148
-		if(!isset(self::$levelMap[LoggerLevel::INFO])) {
148
+		if (!isset(self::$levelMap[LoggerLevel::INFO])) {
149 149
 			self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6);
150 150
 		}
151 151
 		return self::$levelMap[LoggerLevel::INFO];
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return LoggerLevel
158 158
 	 */
159 159
 	public static function getLevelDebug() {
160
-		if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
160
+		if (!isset(self::$levelMap[LoggerLevel::DEBUG])) {
161 161
 			self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7);
162 162
 		}
163 163
 		return self::$levelMap[LoggerLevel::DEBUG];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 * @return LoggerLevel
170 170
 	 */
171 171
 	public static function getLevelAll() {
172
-		if(!isset(self::$levelMap[LoggerLevel::ALL])) {
172
+		if (!isset(self::$levelMap[LoggerLevel::ALL])) {
173 173
 			self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7);
174 174
 		}
175 175
 		return self::$levelMap[LoggerLevel::ALL];
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 	 * @static 
226 226
 	 */
227 227
 	public static function toLevel($arg, $defaultLevel = null) {
228
-		if($defaultLevel === null) {
228
+		if ($defaultLevel === null) {
229 229
 			return self::toLevel($arg, self::getLevelDebug());
230 230
 		} else {
231
-			if(is_int($arg)) {
232
-				switch($arg) {
231
+			if (is_int($arg)) {
232
+				switch ($arg) {
233 233
 					case self::ALL:	return self::getLevelAll();
234 234
 					case self::DEBUG: return self::getLevelDebug();
235 235
 					case self::INFO: return self::getLevelInfo();
@@ -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 'DEBUG': return self::getLevelDebug();
246 246
 					case 'INFO': return self::getLevelInfo();
Please login to merge, or discard this patch.
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * Defines the minimum set of levels recognized by the system, that is
@@ -33,224 +33,224 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class 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 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 ALL = -2147483647;
43 43
 
44
-	/**
45
-	 * TODO: check if still necessary or to be refactored 
46
-	 * @var integer
47
-	 */
48
-	private $level;
44
+    /**
45
+     * TODO: check if still necessary or to be refactored 
46
+     * @var integer
47
+     */
48
+    private $level;
49 49
   
50
-  	/**
51
-   	 * Contains a list of instantiated levels 
52
-   	 */
53
-  	private static $levelMap;
50
+        /**
51
+         * Contains a list of instantiated levels 
52
+         */
53
+        private static $levelMap;
54 54
   	
55
-	/**
56
-	 * @var string
57
-	 */
58
-	private $levelStr;
55
+    /**
56
+     * @var string
57
+     */
58
+    private $levelStr;
59 59
   
60
-	/**
61
-	 * @var integer
62
-	 */
63
-	private $syslogEquivalent;
60
+    /**
61
+     * @var integer
62
+     */
63
+    private $syslogEquivalent;
64 64
 
65
-	/**
66
-	 * Constructor
67
-	 *
68
-	 * @param integer $level
69
-	 * @param string $levelStr
70
-	 * @param integer $syslogEquivalent
71
-	 */
72
-	private function __construct($level, $levelStr, $syslogEquivalent) {
73
-		$this->level = $level;
74
-		$this->levelStr = $levelStr;
75
-		$this->syslogEquivalent = $syslogEquivalent;
76
-	}
65
+    /**
66
+     * Constructor
67
+     *
68
+     * @param integer $level
69
+     * @param string $levelStr
70
+     * @param integer $syslogEquivalent
71
+     */
72
+    private function __construct($level, $levelStr, $syslogEquivalent) {
73
+        $this->level = $level;
74
+        $this->levelStr = $levelStr;
75
+        $this->syslogEquivalent = $syslogEquivalent;
76
+    }
77 77
 
78
-	/**
79
-	 * Two priorities are equal if their level fields are equal.
80
-	 *
81
-	 * @param object $o
82
-	 * @return boolean 
83
-	 */
84
-	public function equals($o) {
85
-		if($o instanceof LoggerLevel) {
86
-			if($this->level == $o->level) {
87
-			    return true;
88
-			}
89
-		} else {
90
-			return false;
91
-		}
92
-	}
78
+    /**
79
+     * Two priorities are equal if their level fields are equal.
80
+     *
81
+     * @param object $o
82
+     * @return boolean 
83
+     */
84
+    public function equals($o) {
85
+        if($o instanceof LoggerLevel) {
86
+            if($this->level == $o->level) {
87
+                return true;
88
+            }
89
+        } else {
90
+            return false;
91
+        }
92
+    }
93 93
 	
94
-	/**
95
-	 * Returns an Off Level
96
-	 * @static
97
-	 * @return LoggerLevel
98
-	 */
99
-	public static function getLevelOff() {
100
-		if(!isset(self::$levelMap[LoggerLevel::OFF])) {
101
-			self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0);
102
-		}
103
-		return self::$levelMap[LoggerLevel::OFF];
104
-	}
94
+    /**
95
+     * Returns an Off Level
96
+     * @static
97
+     * @return LoggerLevel
98
+     */
99
+    public static function getLevelOff() {
100
+        if(!isset(self::$levelMap[LoggerLevel::OFF])) {
101
+            self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0);
102
+        }
103
+        return self::$levelMap[LoggerLevel::OFF];
104
+    }
105 105
 
106
-	/**
107
-	 * Returns a Fatal Level
108
-	 * @static
109
-	 * @return LoggerLevel
110
-	 */
111
-	public static function getLevelFatal() {
112
-		if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
113
-			self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0);
114
-		}
115
-		return self::$levelMap[LoggerLevel::FATAL];
116
-	}
106
+    /**
107
+     * Returns a Fatal Level
108
+     * @static
109
+     * @return LoggerLevel
110
+     */
111
+    public static function getLevelFatal() {
112
+        if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
113
+            self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0);
114
+        }
115
+        return self::$levelMap[LoggerLevel::FATAL];
116
+    }
117 117
 	
118
-	/**
119
-	 * Returns an Error Level
120
-	 * @static
121
-	 * @return LoggerLevel
122
-	 */
123
-	public static function getLevelError() {
124
-		if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
125
-			self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3);
126
-		}
127
-		return self::$levelMap[LoggerLevel::ERROR];
128
-	}
118
+    /**
119
+     * Returns an Error Level
120
+     * @static
121
+     * @return LoggerLevel
122
+     */
123
+    public static function getLevelError() {
124
+        if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
125
+            self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3);
126
+        }
127
+        return self::$levelMap[LoggerLevel::ERROR];
128
+    }
129 129
 	
130
-	/**
131
-	 * Returns a Warn Level
132
-	 * @static
133
-	 * @return LoggerLevel
134
-	 */
135
-	public static function getLevelWarn() {
136
-		if(!isset(self::$levelMap[LoggerLevel::WARN])) {
137
-			self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4);
138
-		}
139
-		return self::$levelMap[LoggerLevel::WARN];
140
-	}
130
+    /**
131
+     * Returns a Warn Level
132
+     * @static
133
+     * @return LoggerLevel
134
+     */
135
+    public static function getLevelWarn() {
136
+        if(!isset(self::$levelMap[LoggerLevel::WARN])) {
137
+            self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4);
138
+        }
139
+        return self::$levelMap[LoggerLevel::WARN];
140
+    }
141 141
 
142
-	/**
143
-	 * Returns an Info Level
144
-	 * @static
145
-	 * @return LoggerLevel
146
-	 */
147
-	public static function getLevelInfo() {
148
-		if(!isset(self::$levelMap[LoggerLevel::INFO])) {
149
-			self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6);
150
-		}
151
-		return self::$levelMap[LoggerLevel::INFO];
152
-	}
142
+    /**
143
+     * Returns an Info Level
144
+     * @static
145
+     * @return LoggerLevel
146
+     */
147
+    public static function getLevelInfo() {
148
+        if(!isset(self::$levelMap[LoggerLevel::INFO])) {
149
+            self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6);
150
+        }
151
+        return self::$levelMap[LoggerLevel::INFO];
152
+    }
153 153
 
154
-	/**
155
-	 * Returns a Debug Level
156
-	 * @static
157
-	 * @return LoggerLevel
158
-	 */
159
-	public static function getLevelDebug() {
160
-		if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
161
-			self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7);
162
-		}
163
-		return self::$levelMap[LoggerLevel::DEBUG];
164
-	}
154
+    /**
155
+     * Returns a Debug Level
156
+     * @static
157
+     * @return LoggerLevel
158
+     */
159
+    public static function getLevelDebug() {
160
+        if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
161
+            self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7);
162
+        }
163
+        return self::$levelMap[LoggerLevel::DEBUG];
164
+    }
165 165
 
166
-	/**
167
-	 * Returns an All Level
168
-	 * @static
169
-	 * @return LoggerLevel
170
-	 */
171
-	public static function getLevelAll() {
172
-		if(!isset(self::$levelMap[LoggerLevel::ALL])) {
173
-			self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7);
174
-		}
175
-		return self::$levelMap[LoggerLevel::ALL];
176
-	}
166
+    /**
167
+     * Returns an All Level
168
+     * @static
169
+     * @return LoggerLevel
170
+     */
171
+    public static function getLevelAll() {
172
+        if(!isset(self::$levelMap[LoggerLevel::ALL])) {
173
+            self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7);
174
+        }
175
+        return self::$levelMap[LoggerLevel::ALL];
176
+    }
177 177
 	
178
-	/**
179
-	 * Return the syslog equivalent of this priority as an integer.
180
-	 * @final
181
-	 * @return integer
182
-	 */
183
-	public function getSyslogEquivalent() {
184
-		return $this->syslogEquivalent;
185
-	}
178
+    /**
179
+     * Return the syslog equivalent of this priority as an integer.
180
+     * @final
181
+     * @return integer
182
+     */
183
+    public function getSyslogEquivalent() {
184
+        return $this->syslogEquivalent;
185
+    }
186 186
 
187
-	/**
188
-	 * Returns <i>true</i> if this level has a higher or equal
189
-	 * level than the level passed as argument, <i>false</i>
190
-	 * otherwise.  
191
-	 * 
192
-	 * <p>You should think twice before overriding the default
193
-	 * implementation of <i>isGreaterOrEqual</i> method.
194
-	 *
195
-	 * @param LoggerLevel $r
196
-	 * @return boolean
197
-	 */
198
-	public function isGreaterOrEqual($r) {
199
-		return $this->level >= $r->level;
200
-	}
187
+    /**
188
+     * Returns <i>true</i> if this level has a higher or equal
189
+     * level than the level passed as argument, <i>false</i>
190
+     * otherwise.  
191
+     * 
192
+     * <p>You should think twice before overriding the default
193
+     * implementation of <i>isGreaterOrEqual</i> method.
194
+     *
195
+     * @param LoggerLevel $r
196
+     * @return boolean
197
+     */
198
+    public function isGreaterOrEqual($r) {
199
+        return $this->level >= $r->level;
200
+    }
201 201
 
202
-	/**
203
-	 * Returns the string representation of this priority.
204
-	 * @return string
205
-	 * @final
206
-	 */
207
-	public function toString() {
208
-		return $this->levelStr;
209
-	}
202
+    /**
203
+     * Returns the string representation of this priority.
204
+     * @return string
205
+     * @final
206
+     */
207
+    public function toString() {
208
+        return $this->levelStr;
209
+    }
210 210
 
211
-	/**
212
-	 * Returns the integer representation of this level.
213
-	 * @return integer
214
-	 */
215
-	public function toInt() {
216
-		return $this->level;
217
-	}
211
+    /**
212
+     * Returns the integer representation of this level.
213
+     * @return integer
214
+     */
215
+    public function toInt() {
216
+        return $this->level;
217
+    }
218 218
 
219
-	/**
220
-	 * Convert the string passed as argument to a level. If the
221
-	 * conversion fails, then this method returns a DEBUG Level.
222
-	 *
223
-	 * @param mixed $arg
224
-	 * @param LoggerLevel $default
225
-	 * @static 
226
-	 */
227
-	public static function toLevel($arg, $defaultLevel = null) {
228
-		if($defaultLevel === null) {
229
-			return self::toLevel($arg, self::getLevelDebug());
230
-		} else {
231
-			if(is_int($arg)) {
232
-				switch($arg) {
233
-					case self::ALL:	return self::getLevelAll();
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 'DEBUG': return self::getLevelDebug();
246
-					case 'INFO': return self::getLevelInfo();
247
-					case 'WARN': return self::getLevelWarn();
248
-					case 'ERROR': return self::getLevelError();
249
-					case 'FATAL': return self::getLevelFatal();
250
-					case 'OFF':	return self::getLevelOff();
251
-					default: return $defaultLevel;
252
-				}
253
-			}
254
-		}
255
-	}
219
+    /**
220
+     * Convert the string passed as argument to a level. If the
221
+     * conversion fails, then this method returns a DEBUG Level.
222
+     *
223
+     * @param mixed $arg
224
+     * @param LoggerLevel $default
225
+     * @static 
226
+     */
227
+    public static function toLevel($arg, $defaultLevel = null) {
228
+        if($defaultLevel === null) {
229
+            return self::toLevel($arg, self::getLevelDebug());
230
+        } else {
231
+            if(is_int($arg)) {
232
+                switch($arg) {
233
+                    case self::ALL:	return self::getLevelAll();
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 'DEBUG': return self::getLevelDebug();
246
+                    case 'INFO': return self::getLevelInfo();
247
+                    case 'WARN': return self::getLevelWarn();
248
+                    case 'ERROR': return self::getLevelError();
249
+                    case 'FATAL': return self::getLevelFatal();
250
+                    case 'OFF':	return self::getLevelOff();
251
+                    default: return $defaultLevel;
252
+                }
253
+            }
254
+        }
255
+    }
256 256
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerLocationInfo.php 3 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   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * The internal representation of caller location information.
@@ -26,85 +26,85 @@  discard block
 block discarded – undo
26 26
  * @since 0.3
27 27
  */
28 28
 class 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.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,8 +69,8 @@
 block discarded – undo
69 69
 		$this->fileName = isset($trace['file']) ? $trace['file'] : null;
70 70
 		$this->className = isset($trace['class']) ? $trace['class'] : null;
71 71
 		$this->methodName = isset($trace['function']) ? $trace['function'] : null;
72
-		$this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . 
73
-			'(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
72
+		$this->fullInfo = $this->getClassName().'.'.$this->getMethodName(). 
73
+			'('.$this->getFileName().':'.$this->getLineNumber().')';
74 74
 	}
75 75
 
76 76
 	public function getClassName() {
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerLoggingEvent.php 3 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	* LoggerLoggingEvent are filled when actually needed.
118 118
 	*
119 119
 	* @param string $fqcn name of the caller class.
120
-	* @param mixed $logger The {@link Logger} category of this event or the logger name.
120
+	* @param Logger $logger The {@link Logger} category of this event or the logger name.
121 121
 	* @param LoggerLevel $priority The level of this event.
122 122
 	* @param mixed $message The message of this event.
123 123
 	* @param integer $timeStamp the timestamp of this logging event.
@@ -249,6 +249,7 @@  discard block
 block discarded – undo
249 249
 	/**
250 250
 	 * Returns the the context corresponding to the <code>key</code>
251 251
 	 * parameter.
252
+	 * @param string $key
252 253
 	 * @return string
253 254
 	 */
254 255
 	public function getMDC($key) {
@@ -304,7 +305,7 @@  discard block
 block discarded – undo
304 305
 	
305 306
 	/**
306 307
 	 * Calculates the time of this event.
307
-	 * @return the time after event starttime when this event has occured
308
+	 * @return string time after event starttime when this event has occured
308 309
 	 */
309 310
 	public function getTime() {
310 311
         $eventTime = (float)$this->getTimeStamp();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	*/
125 125
 	public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) {
126 126
 		$this->fqcn = $fqcn;
127
-		if($logger instanceof Logger) {
127
+		if ($logger instanceof Logger) {
128 128
 			$this->logger = $logger;
129 129
 			$this->categoryName = $logger->getName();
130 130
 		} else {
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 		}
133 133
 		$this->level = $priority;
134 134
 		$this->message = $message;
135
-		if($timeStamp !== null && is_float($timeStamp)) {
135
+		if ($timeStamp !== null && is_float($timeStamp)) {
136 136
 			$this->timeStamp = $timeStamp;
137 137
 		} else {
138
-			if(function_exists('microtime')) {
138
+			if (function_exists('microtime')) {
139 139
 				// get microtime as float
140 140
 				$this->timeStamp = microtime(true);
141 141
 			} else {
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 	 * @return LoggerLocationInfo
155 155
 	 */
156 156
 	public function getLocationInformation() {
157
-		if($this->locationInfo === null) {
157
+		if ($this->locationInfo === null) {
158 158
 
159 159
 			$locationInfo = array();
160 160
 
161
-			if(function_exists('debug_backtrace')) {
161
+			if (function_exists('debug_backtrace')) {
162 162
 				$trace = debug_backtrace();
163 163
 				$prevHop = null;
164 164
 				// make a downsearch to identify the caller
165 165
 				$hop = array_pop($trace);
166
-				while($hop !== null) {
167
-					if(isset($hop['class'])) {
166
+				while ($hop !== null) {
167
+					if (isset($hop['class'])) {
168 168
 						// we are sometimes in functions = no class available: avoid php warning here
169 169
 						$className = strtolower($hop['class']);
170
-						if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
170
+						if (!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
171 171
 							strtolower(get_parent_class($className)) == 'logger' or
172 172
 							strtolower(get_parent_class($className)) == 'loggercategory')) {
173 173
 							$locationInfo['line'] = $hop['line'];
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 					$hop = array_pop($trace);
180 180
 				}
181 181
 				$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
182
-				if(isset($prevHop['function']) and
182
+				if (isset($prevHop['function']) and
183 183
 					$prevHop['function'] !== 'include' and
184 184
 					$prevHop['function'] !== 'include_once' and
185 185
 					$prevHop['function'] !== 'require' and
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @return mixed
225 225
 	 */
226 226
 	public function getMessage() {
227
-		if($this->message !== null) {
227
+		if ($this->message !== null) {
228 228
 			return $this->message;
229 229
 		} else {
230 230
 			return $this->getRenderedMessage();
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * @return string  
240 240
 	 */
241 241
 	public function getNDC() {
242
-		if($this->ndcLookupRequired) {
242
+		if ($this->ndcLookupRequired) {
243 243
 			$this->ndcLookupRequired = false;
244 244
 			$this->ndc = implode(' ', LoggerNDC::get());
245 245
 		}
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	 * @return string
261 261
 	 */
262 262
 	public function getRenderedMessage() {
263
-		if($this->renderedMessage === null and $this->message !== null) {
264
-			if(is_string($this->message)) {
263
+		if ($this->renderedMessage === null and $this->message !== null) {
264
+			if (is_string($this->message)) {
265 265
 					$this->renderedMessage = $this->message;
266 266
 			} else {
267 267
 			    // $this->logger might be null or an instance of Logger or RootLogger
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			    // TODO: Logger::getHierarchy() is marked @deprecated!
271 271
 				$repository = Logger::getHierarchy();
272 272
 				$rendererMap = $repository->getRendererMap();
273
-				$this->renderedMessage= $rendererMap->findAndRender($this->message);
273
+				$this->renderedMessage = $rendererMap->findAndRender($this->message);
274 274
 			}
275 275
 		}
276 276
 		return $this->renderedMessage;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @static
285 285
 	 */
286 286
 	public static function getStartTime() {
287
-		if(!isset(self::$startTime)) {
287
+		if (!isset(self::$startTime)) {
288 288
 			if (function_exists('microtime')) {
289 289
 				// microtime as float
290 290
 				self::$startTime = microtime(true);
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 	 * @return the time after event starttime when this event has occured
308 308
 	 */
309 309
 	public function getTime() {
310
-        $eventTime = (float)$this->getTimeStamp();
311
-        $eventStartTime = (float)LoggerLoggingEvent::getStartTime();
310
+        $eventTime = (float) $this->getTimeStamp();
311
+        $eventStartTime = (float) LoggerLoggingEvent::getStartTime();
312 312
         return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
313 313
     }
314 314
 	
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public function getThreadName() {
319 319
 		if ($this->threadName === null) {
320
-			$this->threadName = (string)getmypid();
320
+			$this->threadName = (string) getmypid();
321 321
 		}
322 322
 		return $this->threadName;
323 323
 	}
Please login to merge, or discard this patch.
Indentation   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -26,334 +26,334 @@
 block discarded – undo
26 26
  */
27 27
 class LoggerLoggingEvent {
28 28
 
29
-	private static $startTime;
29
+    private static $startTime;
30 30
 
31
-	/** 
32
-	* @var string Fully Qualified Class Name of the calling category class.
33
-	*/
34
-	private $fqcn;
31
+    /** 
32
+     * @var string Fully Qualified Class Name of the calling category class.
33
+     */
34
+    private $fqcn;
35 35
 	
36
-	/**
37
-	* @var Logger reference
38
-	*/
39
-	private $logger = null;
36
+    /**
37
+     * @var Logger reference
38
+     */
39
+    private $logger = null;
40 40
 	
41
-	/** 
42
-	* The category (logger) name.
43
-	* This field will be marked as private in future
44
-	* releases. Please do not access it directly. 
45
-	* Use the {@link getLoggerName()} method instead.
46
-	* @deprecated 
47
-	*/
48
-	private $categoryName;
41
+    /** 
42
+     * The category (logger) name.
43
+     * This field will be marked as private in future
44
+     * releases. Please do not access it directly. 
45
+     * Use the {@link getLoggerName()} method instead.
46
+     * @deprecated 
47
+     */
48
+    private $categoryName;
49 49
 	
50
-	/** 
51
-	* Level of logging event.
52
-	* <p> This field should not be accessed directly. You shoud use the
53
-	* {@link getLevel()} method instead.
54
-	*
55
-	* @deprecated
56
-	* @var LoggerLevel
57
-	*/
58
-	protected $level;
50
+    /** 
51
+     * Level of logging event.
52
+     * <p> This field should not be accessed directly. You shoud use the
53
+     * {@link getLevel()} method instead.
54
+     *
55
+     * @deprecated
56
+     * @var LoggerLevel
57
+     */
58
+    protected $level;
59 59
 	
60
-	/** 
61
-	 * @var string The nested diagnostic context (NDC) of logging event. 
62
-	 */
63
-	private $ndc;
60
+    /** 
61
+     * @var string The nested diagnostic context (NDC) of logging event. 
62
+     */
63
+    private $ndc;
64 64
 	
65
-	/** 
66
-	 * Have we tried to do an NDC lookup? If we did, there is no need
67
-	 * to do it again.	Note that its value is always false when
68
-	 * serialized. Thus, a receiving SocketNode will never use it's own
69
-	 * (incorrect) NDC. See also writeObject method.
70
-	 * @var boolean
71
-	 */
72
-	private $ndcLookupRequired = true;
65
+    /** 
66
+     * Have we tried to do an NDC lookup? If we did, there is no need
67
+     * to do it again.	Note that its value is always false when
68
+     * serialized. Thus, a receiving SocketNode will never use it's own
69
+     * (incorrect) NDC. See also writeObject method.
70
+     * @var boolean
71
+     */
72
+    private $ndcLookupRequired = true;
73 73
 	
74
-	/** 
75
-	 * Have we tried to do an MDC lookup? If we did, there is no need
76
-	 * to do it again.	Note that its value is always false when
77
-	 * serialized. See also the getMDC and getMDCCopy methods.
78
-	 * @var boolean	 
79
-	 */
80
-	private $mdcCopyLookupRequired = true;
74
+    /** 
75
+     * Have we tried to do an MDC lookup? If we did, there is no need
76
+     * to do it again.	Note that its value is always false when
77
+     * serialized. See also the getMDC and getMDCCopy methods.
78
+     * @var boolean	 
79
+     */
80
+    private $mdcCopyLookupRequired = true;
81 81
 	
82
-	/** 
83
-	 * @var mixed The application supplied message of logging event. 
84
-	 */
85
-	private $message;
82
+    /** 
83
+     * @var mixed The application supplied message of logging event. 
84
+     */
85
+    private $message;
86 86
 	
87
-	/** 
88
-	 * The application supplied message rendered through the log4php
89
-	 * objet rendering mechanism. At present renderedMessage == message.
90
-	 * @var string
91
-	 */
92
-	private $renderedMessage = null;
87
+    /** 
88
+     * The application supplied message rendered through the log4php
89
+     * objet rendering mechanism. At present renderedMessage == message.
90
+     * @var string
91
+     */
92
+    private $renderedMessage = null;
93 93
 	
94
-	/** 
95
-	 * The name of thread in which this logging event was generated.
96
-	 * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} 
97
-	 * @var mixed
98
-	 */
99
-	private $threadName = null;
94
+    /** 
95
+     * The name of thread in which this logging event was generated.
96
+     * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} 
97
+     * @var mixed
98
+     */
99
+    private $threadName = null;
100 100
 	
101
-	/** 
102
-	* The number of seconds elapsed from 1/1/1970 until logging event
103
-	* was created plus microseconds if available.
104
-	* @var float
105
-	*/
106
-	public $timeStamp;
101
+    /** 
102
+     * The number of seconds elapsed from 1/1/1970 until logging event
103
+     * was created plus microseconds if available.
104
+     * @var float
105
+     */
106
+    public $timeStamp;
107 107
 	
108
-	/** 
109
-	* @var LoggerLocationInfo Location information for the caller. 
110
-	*/
111
-	private $locationInfo = null;
108
+    /** 
109
+     * @var LoggerLocationInfo Location information for the caller. 
110
+     */
111
+    private $locationInfo = null;
112 112
 	
113
-	/**
114
-	* Instantiate a LoggingEvent from the supplied parameters.
115
-	*
116
-	* <p>Except {@link $timeStamp} all the other fields of
117
-	* LoggerLoggingEvent are filled when actually needed.
118
-	*
119
-	* @param string $fqcn name of the caller class.
120
-	* @param mixed $logger The {@link Logger} category of this event or the logger name.
121
-	* @param LoggerLevel $priority The level of this event.
122
-	* @param mixed $message The message of this event.
123
-	* @param integer $timeStamp the timestamp of this logging event.
124
-	*/
125
-	public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) {
126
-		$this->fqcn = $fqcn;
127
-		if($logger instanceof Logger) {
128
-			$this->logger = $logger;
129
-			$this->categoryName = $logger->getName();
130
-		} else {
131
-			$this->categoryName = strval($logger);
132
-		}
133
-		$this->level = $priority;
134
-		$this->message = $message;
135
-		if($timeStamp !== null && is_float($timeStamp)) {
136
-			$this->timeStamp = $timeStamp;
137
-		} else {
138
-			if(function_exists('microtime')) {
139
-				// get microtime as float
140
-				$this->timeStamp = microtime(true);
141
-			} else {
142
-				$this->timeStamp = floatval(time());
143
-			}
144
-		}
145
-	}
113
+    /**
114
+     * Instantiate a LoggingEvent from the supplied parameters.
115
+     *
116
+     * <p>Except {@link $timeStamp} all the other fields of
117
+     * LoggerLoggingEvent are filled when actually needed.
118
+     *
119
+     * @param string $fqcn name of the caller class.
120
+     * @param mixed $logger The {@link Logger} category of this event or the logger name.
121
+     * @param LoggerLevel $priority The level of this event.
122
+     * @param mixed $message The message of this event.
123
+     * @param integer $timeStamp the timestamp of this logging event.
124
+     */
125
+    public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) {
126
+        $this->fqcn = $fqcn;
127
+        if($logger instanceof Logger) {
128
+            $this->logger = $logger;
129
+            $this->categoryName = $logger->getName();
130
+        } else {
131
+            $this->categoryName = strval($logger);
132
+        }
133
+        $this->level = $priority;
134
+        $this->message = $message;
135
+        if($timeStamp !== null && is_float($timeStamp)) {
136
+            $this->timeStamp = $timeStamp;
137
+        } else {
138
+            if(function_exists('microtime')) {
139
+                // get microtime as float
140
+                $this->timeStamp = microtime(true);
141
+            } else {
142
+                $this->timeStamp = floatval(time());
143
+            }
144
+        }
145
+    }
146 146
 
147
-	/**
148
-	 * Set the location information for this logging event. The collected
149
-	 * information is cached for future use.
150
-	 *
151
-	 * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
152
-	 * to collect informations about caller.</p>
153
-	 * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
154
-	 * @return LoggerLocationInfo
155
-	 */
156
-	public function getLocationInformation() {
157
-		if($this->locationInfo === null) {
147
+    /**
148
+     * Set the location information for this logging event. The collected
149
+     * information is cached for future use.
150
+     *
151
+     * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
152
+     * to collect informations about caller.</p>
153
+     * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
154
+     * @return LoggerLocationInfo
155
+     */
156
+    public function getLocationInformation() {
157
+        if($this->locationInfo === null) {
158 158
 
159
-			$locationInfo = array();
159
+            $locationInfo = array();
160 160
 
161
-			if(function_exists('debug_backtrace')) {
162
-				$trace = debug_backtrace();
163
-				$prevHop = null;
164
-				// make a downsearch to identify the caller
165
-				$hop = array_pop($trace);
166
-				while($hop !== null) {
167
-					if(isset($hop['class'])) {
168
-						// we are sometimes in functions = no class available: avoid php warning here
169
-						$className = strtolower($hop['class']);
170
-						if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
171
-							strtolower(get_parent_class($className)) == 'logger' or
172
-							strtolower(get_parent_class($className)) == 'loggercategory')) {
173
-							$locationInfo['line'] = $hop['line'];
174
-							$locationInfo['file'] = $hop['file'];
175
-							break;
176
-						}
177
-					}
178
-					$prevHop = $hop;
179
-					$hop = array_pop($trace);
180
-				}
181
-				$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
182
-				if(isset($prevHop['function']) and
183
-					$prevHop['function'] !== 'include' and
184
-					$prevHop['function'] !== 'include_once' and
185
-					$prevHop['function'] !== 'require' and
186
-					$prevHop['function'] !== 'require_once') {
161
+            if(function_exists('debug_backtrace')) {
162
+                $trace = debug_backtrace();
163
+                $prevHop = null;
164
+                // make a downsearch to identify the caller
165
+                $hop = array_pop($trace);
166
+                while($hop !== null) {
167
+                    if(isset($hop['class'])) {
168
+                        // we are sometimes in functions = no class available: avoid php warning here
169
+                        $className = strtolower($hop['class']);
170
+                        if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
171
+                            strtolower(get_parent_class($className)) == 'logger' or
172
+                            strtolower(get_parent_class($className)) == 'loggercategory')) {
173
+                            $locationInfo['line'] = $hop['line'];
174
+                            $locationInfo['file'] = $hop['file'];
175
+                            break;
176
+                        }
177
+                    }
178
+                    $prevHop = $hop;
179
+                    $hop = array_pop($trace);
180
+                }
181
+                $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
182
+                if(isset($prevHop['function']) and
183
+                    $prevHop['function'] !== 'include' and
184
+                    $prevHop['function'] !== 'include_once' and
185
+                    $prevHop['function'] !== 'require' and
186
+                    $prevHop['function'] !== 'require_once') {
187 187
 	
188
-					$locationInfo['function'] = $prevHop['function'];
189
-				} else {
190
-					$locationInfo['function'] = 'main';
191
-				}
192
-			}
188
+                    $locationInfo['function'] = $prevHop['function'];
189
+                } else {
190
+                    $locationInfo['function'] = 'main';
191
+                }
192
+            }
193 193
 					 
194
-			$this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn);
195
-		}
196
-		return $this->locationInfo;
197
-	}
194
+            $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn);
195
+        }
196
+        return $this->locationInfo;
197
+    }
198 198
 
199
-	/**
200
-	 * Return the level of this event. Use this form instead of directly
201
-	 * accessing the {@link $level} field.
202
-	 * @return LoggerLevel	
203
-	 */
204
-	public function getLevel() {
205
-		return $this->level;
206
-	}
199
+    /**
200
+     * Return the level of this event. Use this form instead of directly
201
+     * accessing the {@link $level} field.
202
+     * @return LoggerLevel	
203
+     */
204
+    public function getLevel() {
205
+        return $this->level;
206
+    }
207 207
 
208
-	/**
209
-	 * Return the name of the logger. Use this form instead of directly
210
-	 * accessing the {@link $categoryName} field.
211
-	 * @return string  
212
-	 */
213
-	public function getLoggerName() {
214
-		return $this->categoryName;
215
-	}
208
+    /**
209
+     * Return the name of the logger. Use this form instead of directly
210
+     * accessing the {@link $categoryName} field.
211
+     * @return string  
212
+     */
213
+    public function getLoggerName() {
214
+        return $this->categoryName;
215
+    }
216 216
 
217
-	/**
218
-	 * Return the message for this logging event.
219
-	 *
220
-	 * <p>Before serialization, the returned object is the message
221
-	 * passed by the user to generate the logging event. After
222
-	 * serialization, the returned value equals the String form of the
223
-	 * message possibly after object rendering.
224
-	 * @return mixed
225
-	 */
226
-	public function getMessage() {
227
-		if($this->message !== null) {
228
-			return $this->message;
229
-		} else {
230
-			return $this->getRenderedMessage();
231
-		}
232
-	}
217
+    /**
218
+     * Return the message for this logging event.
219
+     *
220
+     * <p>Before serialization, the returned object is the message
221
+     * passed by the user to generate the logging event. After
222
+     * serialization, the returned value equals the String form of the
223
+     * message possibly after object rendering.
224
+     * @return mixed
225
+     */
226
+    public function getMessage() {
227
+        if($this->message !== null) {
228
+            return $this->message;
229
+        } else {
230
+            return $this->getRenderedMessage();
231
+        }
232
+    }
233 233
 
234
-	/**
235
-	 * This method returns the NDC for this event. It will return the
236
-	 * correct content even if the event was generated in a different
237
-	 * thread or even on a different machine. The {@link LoggerNDC::get()} method
238
-	 * should <b>never</b> be called directly.
239
-	 * @return string  
240
-	 */
241
-	public function getNDC() {
242
-		if($this->ndcLookupRequired) {
243
-			$this->ndcLookupRequired = false;
244
-			$this->ndc = implode(' ', LoggerNDC::get());
245
-		}
246
-		return $this->ndc;
247
-	}
234
+    /**
235
+     * This method returns the NDC for this event. It will return the
236
+     * correct content even if the event was generated in a different
237
+     * thread or even on a different machine. The {@link LoggerNDC::get()} method
238
+     * should <b>never</b> be called directly.
239
+     * @return string  
240
+     */
241
+    public function getNDC() {
242
+        if($this->ndcLookupRequired) {
243
+            $this->ndcLookupRequired = false;
244
+            $this->ndc = implode(' ', LoggerNDC::get());
245
+        }
246
+        return $this->ndc;
247
+    }
248 248
 
249
-	/**
250
-	 * Returns the the context corresponding to the <code>key</code>
251
-	 * parameter.
252
-	 * @return string
253
-	 */
254
-	public function getMDC($key) {
255
-		return LoggerMDC::get($key);
256
-	}
249
+    /**
250
+     * Returns the the context corresponding to the <code>key</code>
251
+     * parameter.
252
+     * @return string
253
+     */
254
+    public function getMDC($key) {
255
+        return LoggerMDC::get($key);
256
+    }
257 257
 
258
-	/**
259
-	 * Render message.
260
-	 * @return string
261
-	 */
262
-	public function getRenderedMessage() {
263
-		if($this->renderedMessage === null and $this->message !== null) {
264
-			if(is_string($this->message)) {
265
-					$this->renderedMessage = $this->message;
266
-			} else {
267
-			    // $this->logger might be null or an instance of Logger or RootLogger
268
-			    // But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is
269
-			    // no need figure out which one is $this->logger part of.
270
-			    // TODO: Logger::getHierarchy() is marked @deprecated!
271
-				$repository = Logger::getHierarchy();
272
-				$rendererMap = $repository->getRendererMap();
273
-				$this->renderedMessage= $rendererMap->findAndRender($this->message);
274
-			}
275
-		}
276
-		return $this->renderedMessage;
277
-	}
258
+    /**
259
+     * Render message.
260
+     * @return string
261
+     */
262
+    public function getRenderedMessage() {
263
+        if($this->renderedMessage === null and $this->message !== null) {
264
+            if(is_string($this->message)) {
265
+                    $this->renderedMessage = $this->message;
266
+            } else {
267
+                // $this->logger might be null or an instance of Logger or RootLogger
268
+                // But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is
269
+                // no need figure out which one is $this->logger part of.
270
+                // TODO: Logger::getHierarchy() is marked @deprecated!
271
+                $repository = Logger::getHierarchy();
272
+                $rendererMap = $repository->getRendererMap();
273
+                $this->renderedMessage= $rendererMap->findAndRender($this->message);
274
+            }
275
+        }
276
+        return $this->renderedMessage;
277
+    }
278 278
 
279
-	/**
280
-	 * Returns the time when the application started, in seconds
281
-	 * elapsed since 01.01.1970 plus microseconds if available.
282
-	 *
283
-	 * @return float
284
-	 * @static
285
-	 */
286
-	public static function getStartTime() {
287
-		if(!isset(self::$startTime)) {
288
-			if (function_exists('microtime')) {
289
-				// microtime as float
290
-				self::$startTime = microtime(true);
291
-			} else {
292
-				self::$startTime = floatval(time());
293
-			}
294
-		}
295
-		return self::$startTime; 
296
-	}
279
+    /**
280
+     * Returns the time when the application started, in seconds
281
+     * elapsed since 01.01.1970 plus microseconds if available.
282
+     *
283
+     * @return float
284
+     * @static
285
+     */
286
+    public static function getStartTime() {
287
+        if(!isset(self::$startTime)) {
288
+            if (function_exists('microtime')) {
289
+                // microtime as float
290
+                self::$startTime = microtime(true);
291
+            } else {
292
+                self::$startTime = floatval(time());
293
+            }
294
+        }
295
+        return self::$startTime; 
296
+    }
297 297
 
298
-	/**
299
-	 * @return float
300
-	 */
301
-	public function getTimeStamp() {
302
-		return $this->timeStamp;
303
-	}
298
+    /**
299
+     * @return float
300
+     */
301
+    public function getTimeStamp() {
302
+        return $this->timeStamp;
303
+    }
304 304
 	
305
-	/**
306
-	 * Calculates the time of this event.
307
-	 * @return the time after event starttime when this event has occured
308
-	 */
309
-	public function getTime() {
305
+    /**
306
+     * Calculates the time of this event.
307
+     * @return the time after event starttime when this event has occured
308
+     */
309
+    public function getTime() {
310 310
         $eventTime = (float)$this->getTimeStamp();
311 311
         $eventStartTime = (float)LoggerLoggingEvent::getStartTime();
312 312
         return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
313 313
     }
314 314
 	
315
-	/**
316
-	 * @return mixed
317
-	 */
318
-	public function getThreadName() {
319
-		if ($this->threadName === null) {
320
-			$this->threadName = (string)getmypid();
321
-		}
322
-		return $this->threadName;
323
-	}
315
+    /**
316
+     * @return mixed
317
+     */
318
+    public function getThreadName() {
319
+        if ($this->threadName === null) {
320
+            $this->threadName = (string)getmypid();
321
+        }
322
+        return $this->threadName;
323
+    }
324 324
 
325
-	/**
326
-	 * @return mixed null
327
-	 */
328
-	public function getThrowableInformation() {
329
-		return null;
330
-	}
325
+    /**
326
+     * @return mixed null
327
+     */
328
+    public function getThrowableInformation() {
329
+        return null;
330
+    }
331 331
 	
332
-	/**
333
-	 * Serialize this object
334
-	 * @return string
335
-	 */
336
-	public function toString() {
337
-		serialize($this);
338
-	}
332
+    /**
333
+     * Serialize this object
334
+     * @return string
335
+     */
336
+    public function toString() {
337
+        serialize($this);
338
+    }
339 339
 	
340
-	/**
341
-	 * Avoid serialization of the {@link $logger} object
342
-	 */
343
-	public function __sleep() {
344
-		return array(
345
-			'fqcn',
346
-			'categoryName',
347
-			'level',
348
-			'ndc',
349
-			'ndcLookupRequired',
350
-			'message',
351
-			'renderedMessage',
352
-			'threadName',
353
-			'timeStamp',
354
-			'locationInfo',
355
-		);
356
-	}
340
+    /**
341
+     * Avoid serialization of the {@link $logger} object
342
+     */
343
+    public function __sleep() {
344
+        return array(
345
+            'fqcn',
346
+            'categoryName',
347
+            'level',
348
+            'ndc',
349
+            'ndcLookupRequired',
350
+            'message',
351
+            'renderedMessage',
352
+            'threadName',
353
+            'timeStamp',
354
+            'locationInfo',
355
+        );
356
+    }
357 357
 
358 358
 }
359 359
 
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerReflectionUtils.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,6 +47,10 @@  discard block
 block discarded – undo
47 47
 	 * @static
48 48
 	 */
49 49
 	 // TODO: check, if this is really useful
50
+
51
+	/**
52
+	 * @param string $prefix
53
+	 */
50 54
 	public static function setPropertiesByObject($obj, $properties, $prefix) {
51 55
 		$pSetter = new LoggerReflectionUtils($obj);
52 56
 		return $pSetter->setProperties($properties, $prefix);
@@ -123,7 +127,7 @@  discard block
 block discarded – undo
123 127
 	/**
124 128
 	 * Creates an instances from the given class name.
125 129
 	 *
126
-	 * @param string $classname
130
+	 * @param string $class
127 131
 	 * @return an object from the class with the given classname
128 132
 	 */
129 133
 	public static function createObject($class) {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -1,140 +1,140 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- * 
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     * 
18
+     * @package log4php
19
+     */
20 20
  
21
- /**
22
-  * Provides methods for reflective use on php objects
23
-  * @package log4php
24
-  */
21
+    /**
22
+     * Provides methods for reflective use on php objects
23
+     * @package log4php
24
+     */
25 25
 class LoggerReflectionUtils {
26
-		/** the target object */
27
-	private $obj;
26
+        /** the target object */
27
+    private $obj;
28 28
   
29
-	/**
30
-	 * Create a new LoggerReflectionUtils for the specified Object. 
31
-	 * This is done in prepartion for invoking {@link setProperty()} 
32
-	 * one or more times.
33
-	 * @param object &$obj the object for which to set properties
34
-	 */
35
-	public function __construct($obj) {
36
-		$this->obj = $obj;
37
-	}
29
+    /**
30
+     * Create a new LoggerReflectionUtils for the specified Object. 
31
+     * This is done in prepartion for invoking {@link setProperty()} 
32
+     * one or more times.
33
+     * @param object &$obj the object for which to set properties
34
+     */
35
+    public function __construct($obj) {
36
+        $this->obj = $obj;
37
+    }
38 38
   
39
-	/**
40
-	 * Set the properties of an object passed as a parameter in one
41
-	 * go. The <code>properties</code> are parsed relative to a
42
-	 * <code>prefix</code>.
43
-	 *
44
-	 * @param object $obj The object to configure.
45
-	 * @param array $properties An array containing keys and values.
46
-	 * @param string $prefix Only keys having the specified prefix will be set.
47
-	 * @static
48
-	 */
49
-	 // TODO: check, if this is really useful
50
-	public static function setPropertiesByObject($obj, $properties, $prefix) {
51
-		$pSetter = new LoggerReflectionUtils($obj);
52
-		return $pSetter->setProperties($properties, $prefix);
53
-	}
39
+    /**
40
+     * Set the properties of an object passed as a parameter in one
41
+     * go. The <code>properties</code> are parsed relative to a
42
+     * <code>prefix</code>.
43
+     *
44
+     * @param object $obj The object to configure.
45
+     * @param array $properties An array containing keys and values.
46
+     * @param string $prefix Only keys having the specified prefix will be set.
47
+     * @static
48
+     */
49
+        // TODO: check, if this is really useful
50
+    public static function setPropertiesByObject($obj, $properties, $prefix) {
51
+        $pSetter = new LoggerReflectionUtils($obj);
52
+        return $pSetter->setProperties($properties, $prefix);
53
+    }
54 54
   
55 55
 
56
-	/**
57
-	 * Set the properites for the object that match the
58
-	 * <code>prefix</code> passed as parameter.
59
-	 * 
60
-	 * Example:
61
-	 * 
62
-	 * $arr['xxxname'] = 'Joe';
63
- 	 * $arr['xxxmale'] = true;
64
-	 * and prefix xxx causes setName and setMale.	
65
-	 *
66
-	 * @param array $properties An array containing keys and values.
67
-	 * @param string $prefix Only keys having the specified prefix will be set.
68
-	 */
69
-	 // TODO: check, if this is really useful
70
-	public function setProperties($properties, $prefix) {
71
-		$len = strlen($prefix);
72
-		while(list($key,) = each($properties)) {
73
-			if(strpos($key, $prefix) === 0) {
74
-				if(strpos($key, '.', ($len + 1)) > 0) {
75
-					continue;
76
-				}
77
-				$value = LoggerOptionConverter::findAndSubst($key, $properties);
78
-				$key = substr($key, $len);
79
-				if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
80
-					continue;
81
-				}
82
-				$this->setProperty($key, $value);
83
-			}
84
-		}
85
-		$this->activate();
86
-	}
56
+    /**
57
+     * Set the properites for the object that match the
58
+     * <code>prefix</code> passed as parameter.
59
+     * 
60
+     * Example:
61
+     * 
62
+     * $arr['xxxname'] = 'Joe';
63
+     * $arr['xxxmale'] = true;
64
+     * and prefix xxx causes setName and setMale.	
65
+     *
66
+     * @param array $properties An array containing keys and values.
67
+     * @param string $prefix Only keys having the specified prefix will be set.
68
+     */
69
+        // TODO: check, if this is really useful
70
+    public function setProperties($properties, $prefix) {
71
+        $len = strlen($prefix);
72
+        while(list($key,) = each($properties)) {
73
+            if(strpos($key, $prefix) === 0) {
74
+                if(strpos($key, '.', ($len + 1)) > 0) {
75
+                    continue;
76
+                }
77
+                $value = LoggerOptionConverter::findAndSubst($key, $properties);
78
+                $key = substr($key, $len);
79
+                if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
80
+                    continue;
81
+                }
82
+                $this->setProperty($key, $value);
83
+            }
84
+        }
85
+        $this->activate();
86
+    }
87 87
 	
88
-	/**
89
-	 * Set a property on this PropertySetter's Object. If successful, this
90
-	 * method will invoke a setter method on the underlying Object. The
91
-	 * setter is the one for the specified property name and the value is
92
-	 * determined partly from the setter argument type and partly from the
93
-	 * value specified in the call to this method.
94
-	 *
95
-	 * <p>If the setter expects a String no conversion is necessary.
96
-	 * If it expects an int, then an attempt is made to convert 'value'
97
-	 * to an int using new Integer(value). If the setter expects a boolean,
98
-	 * the conversion is by new Boolean(value).
99
-	 *
100
-	 * @param string $name	  name of the property
101
-	 * @param string $value	  String value of the property
102
-	 */
103
-	public function setProperty($name, $value) {
104
-		if($value === null) {
105
-			return;
106
-		}
88
+    /**
89
+     * Set a property on this PropertySetter's Object. If successful, this
90
+     * method will invoke a setter method on the underlying Object. The
91
+     * setter is the one for the specified property name and the value is
92
+     * determined partly from the setter argument type and partly from the
93
+     * value specified in the call to this method.
94
+     *
95
+     * <p>If the setter expects a String no conversion is necessary.
96
+     * If it expects an int, then an attempt is made to convert 'value'
97
+     * to an int using new Integer(value). If the setter expects a boolean,
98
+     * the conversion is by new Boolean(value).
99
+     *
100
+     * @param string $name	  name of the property
101
+     * @param string $value	  String value of the property
102
+     */
103
+    public function setProperty($name, $value) {
104
+        if($value === null) {
105
+            return;
106
+        }
107 107
 		
108
-		$method = "set" . ucfirst($name);
108
+        $method = "set" . ucfirst($name);
109 109
 		
110
-		if(!method_exists($this->obj, $method)) {
111
-			throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
112
-		} else {
113
-			return call_user_func(array($this->obj, $method), $value);
114
-		} 
115
-	}
110
+        if(!method_exists($this->obj, $method)) {
111
+            throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
112
+        } else {
113
+            return call_user_func(array($this->obj, $method), $value);
114
+        } 
115
+    }
116 116
   
117
-	public function activate() {
118
-		if(method_exists($this->obj, 'activateoptions')) {
119
-			return call_user_func(array($this->obj, 'activateoptions'));
120
-		} 
121
-	}
117
+    public function activate() {
118
+        if(method_exists($this->obj, 'activateoptions')) {
119
+            return call_user_func(array($this->obj, 'activateoptions'));
120
+        } 
121
+    }
122 122
 	
123
-	/**
124
-	 * Creates an instances from the given class name.
125
-	 *
126
-	 * @param string $classname
127
-	 * @return an object from the class with the given classname
128
-	 */
129
-	public static function createObject($class) {
130
-		if(!empty($class)) {
131
-			$class = basename($class);
132
-			return new $class();
133
-		}
134
-		return null;
135
-	}
123
+    /**
124
+     * Creates an instances from the given class name.
125
+     *
126
+     * @param string $classname
127
+     * @return an object from the class with the given classname
128
+     */
129
+    public static function createObject($class) {
130
+        if(!empty($class)) {
131
+            $class = basename($class);
132
+            return new $class();
133
+        }
134
+        return null;
135
+    }
136 136
 	
137
-	/**
137
+    /**
138 138
      * @param object $object
139 139
      * @param string $name
140 140
      * @param mixed $value
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/renderers/LoggerRendererMap.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,6 @@  discard block
 block discarded – undo
58 58
 	 * Add a renderer to a hierarchy passed as parameter.
59 59
 	 * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
60 60
 	 *
61
-	 * @param LoggerHierarchy $repository a logger repository.
62 61
 	 * @param string $renderedClassName
63 62
 	 * @param string $renderingClassName
64 63
 	 * @static
@@ -108,7 +107,7 @@  discard block
 block discarded – undo
108 107
 	 * class of the object parameter.
109 108
 	 * 
110 109
 	 * @param mixed $o
111
-	 * @return string
110
+	 * @return LoggerRendererObject
112 111
 	 */
113 112
 	public function getByObject($o) {
114 113
 		return ($o == null) ? null : $this->getByClassName(get_class($o));
Please login to merge, or discard this patch.
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Licensed to the Apache Software Foundation (ASF) under one or more
4
- * contributor license agreements. See the NOTICE file distributed with
5
- * this work for additional information regarding copyright ownership.
6
- * The ASF licenses this file to You under the Apache License, Version 2.0
7
- * (the "License"); you may not use this file except in compliance with
8
- * the License. You may obtain a copy of the License at
9
- *
10
- *	   http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * @package log4php
19
- */
3
+     * Licensed to the Apache Software Foundation (ASF) under one or more
4
+     * contributor license agreements. See the NOTICE file distributed with
5
+     * this work for additional information regarding copyright ownership.
6
+     * The ASF licenses this file to You under the Apache License, Version 2.0
7
+     * (the "License"); you may not use this file except in compliance with
8
+     * the License. You may obtain a copy of the License at
9
+     *
10
+     *	   http://www.apache.org/licenses/LICENSE-2.0
11
+     *
12
+     * Unless required by applicable law or agreed to in writing, software
13
+     * distributed under the License is distributed on an "AS IS" BASIS,
14
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+     * See the License for the specific language governing permissions and
16
+     * limitations under the License.
17
+     *
18
+     * @package log4php
19
+     */
20 20
 
21 21
 /**
22 22
  * Log objects using customized renderers that implement {@link LoggerRendererObject}.
@@ -36,114 +36,114 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class LoggerRendererMap {
38 38
 
39
-	/**
40
-	 * @var array
41
-	 */
42
-	private $map;
39
+    /**
40
+     * @var array
41
+     */
42
+    private $map;
43 43
 
44
-	/**
45
-	 * @var LoggerDefaultRenderer
46
-	 */
47
-	private $defaultRenderer;
44
+    /**
45
+     * @var LoggerDefaultRenderer
46
+     */
47
+    private $defaultRenderer;
48 48
 
49
-	/**
50
-	 * Constructor
51
-	 */
52
-	public function __construct() {
53
-		$this->map = array();
54
-		$this->defaultRenderer = new LoggerRendererDefault();
55
-	}
49
+    /**
50
+     * Constructor
51
+     */
52
+    public function __construct() {
53
+        $this->map = array();
54
+        $this->defaultRenderer = new LoggerRendererDefault();
55
+    }
56 56
 
57
-	/**
58
-	 * Add a renderer to a hierarchy passed as parameter.
59
-	 * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
60
-	 *
61
-	 * @param LoggerHierarchy $repository a logger repository.
62
-	 * @param string $renderedClassName
63
-	 * @param string $renderingClassName
64
-	 * @static
65
-	 */
66
-	public function addRenderer($renderedClassName, $renderingClassName) {
67
-		$renderer = LoggerReflectionUtils::createObject($renderingClassName);
68
-		if($renderer == null) {
69
-			return;
70
-		} else {
71
-			$this->put($renderedClassName, $renderer);
72
-		}
73
-	}
57
+    /**
58
+     * Add a renderer to a hierarchy passed as parameter.
59
+     * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
60
+     *
61
+     * @param LoggerHierarchy $repository a logger repository.
62
+     * @param string $renderedClassName
63
+     * @param string $renderingClassName
64
+     * @static
65
+     */
66
+    public function addRenderer($renderedClassName, $renderingClassName) {
67
+        $renderer = LoggerReflectionUtils::createObject($renderingClassName);
68
+        if($renderer == null) {
69
+            return;
70
+        } else {
71
+            $this->put($renderedClassName, $renderer);
72
+        }
73
+    }
74 74
 
75 75
 
76
-	/**
77
-	 * Find the appropriate renderer for the class type of the
78
-	 * <var>o</var> parameter. 
79
-	 *
80
-	 * This is accomplished by calling the {@link getByObject()} 
81
-	 * method if <var>o</var> is object or using {@link LoggerRendererDefault}. 
82
-	 * Once a renderer is found, it is applied on the object <var>o</var> and 
83
-	 * the result is returned as a string.
84
-	 *
85
-	 * @param mixed $o
86
-	 * @return string 
87
-	 */
88
-	public function findAndRender($o) {
89
-		if($o == null) {
90
-			return null;
91
-		} else {
92
-			if(is_object($o)) {
93
-				$renderer = $this->getByObject($o);
94
-				if($renderer !== null) {
95
-					return $renderer->render($o);
96
-				} else {
97
-					return null;
98
-				}
99
-			} else {
100
-				$renderer = $this->defaultRenderer;
101
-				return $renderer->render($o);
102
-			}
103
-		}
104
-	}
76
+    /**
77
+     * Find the appropriate renderer for the class type of the
78
+     * <var>o</var> parameter. 
79
+     *
80
+     * This is accomplished by calling the {@link getByObject()} 
81
+     * method if <var>o</var> is object or using {@link LoggerRendererDefault}. 
82
+     * Once a renderer is found, it is applied on the object <var>o</var> and 
83
+     * the result is returned as a string.
84
+     *
85
+     * @param mixed $o
86
+     * @return string 
87
+     */
88
+    public function findAndRender($o) {
89
+        if($o == null) {
90
+            return null;
91
+        } else {
92
+            if(is_object($o)) {
93
+                $renderer = $this->getByObject($o);
94
+                if($renderer !== null) {
95
+                    return $renderer->render($o);
96
+                } else {
97
+                    return null;
98
+                }
99
+            } else {
100
+                $renderer = $this->defaultRenderer;
101
+                return $renderer->render($o);
102
+            }
103
+        }
104
+    }
105 105
 
106
-	/**
107
-	 * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
108
-	 * class of the object parameter.
109
-	 * 
110
-	 * @param mixed $o
111
-	 * @return string
112
-	 */
113
-	public function getByObject($o) {
114
-		return ($o == null) ? null : $this->getByClassName(get_class($o));
115
-	}
106
+    /**
107
+     * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
108
+     * class of the object parameter.
109
+     * 
110
+     * @param mixed $o
111
+     * @return string
112
+     */
113
+    public function getByObject($o) {
114
+        return ($o == null) ? null : $this->getByClassName(get_class($o));
115
+    }
116 116
 
117 117
 
118
-	/**
119
-	 * Search the parents of <var>clazz</var> for a renderer. 
120
-	 *
121
-	 * The renderer closest in the hierarchy will be returned. If no
122
-	 * renderers could be found, then the default renderer is returned.
123
-	 *
124
-	 * @param string $class
125
-	 * @return LoggerRendererObject
126
-	 */
127
-	public function getByClassName($class) {
128
-		$r = null;
129
-		for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
130
-			if(isset($this->map[$c])) {
131
-				return $this->map[$c];
132
-			}
133
-		}
134
-		return $this->defaultRenderer;
135
-	}
118
+    /**
119
+     * Search the parents of <var>clazz</var> for a renderer. 
120
+     *
121
+     * The renderer closest in the hierarchy will be returned. If no
122
+     * renderers could be found, then the default renderer is returned.
123
+     *
124
+     * @param string $class
125
+     * @return LoggerRendererObject
126
+     */
127
+    public function getByClassName($class) {
128
+        $r = null;
129
+        for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
130
+            if(isset($this->map[$c])) {
131
+                return $this->map[$c];
132
+            }
133
+        }
134
+        return $this->defaultRenderer;
135
+    }
136 136
 
137
-	public function clear() {
138
-		$this->map = array();
139
-	}
137
+    public function clear() {
138
+        $this->map = array();
139
+    }
140 140
 
141
-	/**
142
-	 * Register a {@link LoggerRendererObject} for <var>clazz</var>.
143
-	 * @param string $class
144
-	 * @param LoggerRendererObject $or
145
-	 */
146
-	private function put($class, $or) {
147
-		$this->map[strtolower($class)] = $or;
148
-	}
141
+    /**
142
+     * Register a {@link LoggerRendererObject} for <var>clazz</var>.
143
+     * @param string $class
144
+     * @param LoggerRendererObject $or
145
+     */
146
+    private function put($class, $or) {
147
+        $this->map[strtolower($class)] = $or;
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function addRenderer($renderedClassName, $renderingClassName) {
67 67
 		$renderer = LoggerReflectionUtils::createObject($renderingClassName);
68
-		if($renderer == null) {
68
+		if ($renderer == null) {
69 69
 			return;
70 70
 		} else {
71 71
 			$this->put($renderedClassName, $renderer);
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 * @return string 
87 87
 	 */
88 88
 	public function findAndRender($o) {
89
-		if($o == null) {
89
+		if ($o == null) {
90 90
 			return null;
91 91
 		} else {
92
-			if(is_object($o)) {
92
+			if (is_object($o)) {
93 93
 				$renderer = $this->getByObject($o);
94
-				if($renderer !== null) {
94
+				if ($renderer !== null) {
95 95
 					return $renderer->render($o);
96 96
 				} else {
97 97
 					return null;
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function getByClassName($class) {
128 128
 		$r = null;
129
-		for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
130
-			if(isset($this->map[$c])) {
129
+		for ($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
130
+			if (isset($this->map[$c])) {
131 131
 				return $this->map[$c];
132 132
 			}
133 133
 		}
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/abstract_renderer.cls.php 5 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,6 @@
 block discarded – undo
98 98
   /**
99 99
    * Render a background image over a rectangular area
100 100
    *
101
-   * @param string $img      The background image to load
102 101
    * @param float  $x        The left edge of the rectangular area
103 102
    * @param float  $y        The top edge of the rectangular area
104 103
    * @param float  $width    The width of the rectangular area
Please login to merge, or discard this patch.
Indentation   +271 added lines, -271 removed lines patch added patch discarded remove patch
@@ -60,57 +60,57 @@  discard block
 block discarded – undo
60 60
  */
61 61
 abstract class Abstract_Renderer {
62 62
 
63
-  /**
64
-   * Rendering backend
65
-   *
66
-   * @var Canvas
67
-   */
68
-  protected $_canvas;
69
-
70
-  /**
71
-   * Current dompdf instance
72
-   *
73
-   * @var DOMPDF
74
-   */
75
-  protected $_dompdf;
63
+    /**
64
+     * Rendering backend
65
+     *
66
+     * @var Canvas
67
+     */
68
+    protected $_canvas;
69
+
70
+    /**
71
+     * Current dompdf instance
72
+     *
73
+     * @var DOMPDF
74
+     */
75
+    protected $_dompdf;
76 76
   
77
-  /**
78
-   * Class constructor
79
-   *
80
-   * @param DOMPDF $dompdf The current dompdf instance
81
-   */
82
-  function __construct(DOMPDF $dompdf) {
77
+    /**
78
+     * Class constructor
79
+     *
80
+     * @param DOMPDF $dompdf The current dompdf instance
81
+     */
82
+    function __construct(DOMPDF $dompdf) {
83 83
     $this->_dompdf = $dompdf;
84 84
     $this->_canvas = $dompdf->get_canvas();
85
-  }
85
+    }
86 86
   
87
-  /**
88
-   * Render a frame.
89
-   *
90
-   * Specialized in child classes
91
-   *
92
-   * @param Frame $frame The frame to render
93
-   */
94
-  abstract function render(Frame $frame);
95
-
96
-  //........................................................................
97
-
98
-  /**
99
-   * Render a background image over a rectangular area
100
-   *
101
-   * @param string $img      The background image to load
102
-   * @param float  $x        The left edge of the rectangular area
103
-   * @param float  $y        The top edge of the rectangular area
104
-   * @param float  $width    The width of the rectangular area
105
-   * @param float  $height   The height of the rectangular area
106
-   * @param Style  $style    The associated Style object
107
-   */
108
-  protected function _background_image($url, $x, $y, $width, $height, $style) {
87
+    /**
88
+     * Render a frame.
89
+     *
90
+     * Specialized in child classes
91
+     *
92
+     * @param Frame $frame The frame to render
93
+     */
94
+    abstract function render(Frame $frame);
95
+
96
+    //........................................................................
97
+
98
+    /**
99
+     * Render a background image over a rectangular area
100
+     *
101
+     * @param string $img      The background image to load
102
+     * @param float  $x        The left edge of the rectangular area
103
+     * @param float  $y        The top edge of the rectangular area
104
+     * @param float  $width    The width of the rectangular area
105
+     * @param float  $height   The height of the rectangular area
106
+     * @param Style  $style    The associated Style object
107
+     */
108
+    protected function _background_image($url, $x, $y, $width, $height, $style) {
109 109
     $sheet = $style->get_stylesheet();
110 110
 
111 111
     // Skip degenerate cases
112 112
     if ( $width == 0 || $height == 0 )
113
-      return;
113
+        return;
114 114
 
115 115
     //debugpng
116 116
     if (DEBUGPNG) print '[_background_image '.$url.']';
@@ -122,24 +122,24 @@  discard block
 block discarded – undo
122 122
 
123 123
     // Bail if the image is no good
124 124
     if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" )
125
-      return;
125
+        return;
126 126
 
127
-	//Try to optimize away reading and composing of same background multiple times
128
-	//Postponing read with imagecreatefrom   ...()
129
-	//final composition paramters and name not known yet
130
-	//Therefore read dimension directly from file, instead of creating gd object first.
127
+    //Try to optimize away reading and composing of same background multiple times
128
+    //Postponing read with imagecreatefrom   ...()
129
+    //final composition paramters and name not known yet
130
+    //Therefore read dimension directly from file, instead of creating gd object first.
131 131
     //$img_w = imagesx($src); $img_h = imagesy($src);
132 132
 
133 133
     list($img_w, $img_h) = getimagesize($img);
134 134
     if (!isset($img_w) || $img_w == 0 || !isset($img_h) || $img_h == 0) {
135
-      return;
135
+        return;
136 136
     }
137 137
 
138 138
     $repeat = $style->background_repeat;
139 139
     $bg_color = $style->background_color;
140 140
 
141
-	//Increase background resolution and dependent box size according to image resolution to be placed in
142
-	//Then image can be copied in without resize
141
+    //Increase background resolution and dependent box size according to image resolution to be placed in
142
+    //Then image can be copied in without resize
143 143
     $bg_width = round((float)($width * DOMPDF_DPI) / 72);
144 144
     $bg_height = round((float)($height * DOMPDF_DPI) / 72);
145 145
 
@@ -148,27 +148,27 @@  discard block
 block discarded – undo
148 148
     list($bg_x, $bg_y) = $style->background_position;
149 149
 
150 150
     if ( is_percent($bg_x) ) {
151
-      // The point $bg_x % from the left edge of the image is placed
152
-      // $bg_x % from the left edge of the background rectangle
153
-      $p = ((float)$bg_x)/100.0;
154
-      $x1 = $p * $img_w;
155
-      $x2 = $p * $bg_width;
151
+        // The point $bg_x % from the left edge of the image is placed
152
+        // $bg_x % from the left edge of the background rectangle
153
+        $p = ((float)$bg_x)/100.0;
154
+        $x1 = $p * $img_w;
155
+        $x2 = $p * $bg_width;
156 156
 
157
-      $bg_x = round($x2 - $x1);
157
+        $bg_x = round($x2 - $x1);
158 158
     } else {
159
-      $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72);
159
+        $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72);
160 160
     }
161 161
 
162 162
     if ( is_percent($bg_y) ) {
163
-      // The point $bg_y % from the left edge of the image is placed
164
-      // $bg_y % from the left edge of the background rectangle
165
-      $p = ((float)$bg_y)/100.0;
166
-      $y1 = $p * $img_h;
167
-      $y2 = $p * $bg_height;
163
+        // The point $bg_y % from the left edge of the image is placed
164
+        // $bg_y % from the left edge of the background rectangle
165
+        $p = ((float)$bg_y)/100.0;
166
+        $y1 = $p * $img_h;
167
+        $y2 = $p * $bg_height;
168 168
 
169
-      $bg_y = round($y2 - $y1);
169
+        $bg_y = round($y2 - $y1);
170 170
     } else {
171
-      $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72);
171
+        $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72);
172 172
     }
173 173
 
174 174
     //clip background to the image area on partial repeat. Nothing to do if img off area
@@ -177,79 +177,79 @@  discard block
 block discarded – undo
177 177
     //Handle x/y Dimensions separately
178 178
 
179 179
     if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) {
180
-      //No repeat x
181
-      if ($bg_x < 0) {
180
+        //No repeat x
181
+        if ($bg_x < 0) {
182 182
         $bg_width = $img_w + $bg_x;
183
-      } else {
183
+        } else {
184 184
         $x += ($bg_x * 72)/DOMPDF_DPI;
185 185
         $bg_width = $bg_width - $bg_x;
186 186
         if ($bg_width > $img_w) {
187
-          $bg_width = $img_w;
187
+            $bg_width = $img_w;
188 188
         }
189 189
         $bg_x = 0;
190
-      }
191
-      if ($bg_width <= 0) {
192
-      	return;
193
-      }
194
-      $width = (float)($bg_width * 72)/DOMPDF_DPI;
190
+        }
191
+        if ($bg_width <= 0) {
192
+            return;
193
+        }
194
+        $width = (float)($bg_width * 72)/DOMPDF_DPI;
195 195
     } else {
196
-      //repeat x
197
-      if ($bg_x < 0) {
196
+        //repeat x
197
+        if ($bg_x < 0) {
198 198
         $bg_x = - ((-$bg_x) % $img_w);
199
-      } else {
199
+        } else {
200 200
         $bg_x = $bg_x % $img_w;
201 201
         if ($bg_x > 0) {
202
-          $bg_x -= $img_w;
202
+            $bg_x -= $img_w;
203
+        }
203 204
         }
204
-      }
205 205
     }
206 206
 
207 207
     if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) {
208
-      //no repeat y
209
-      if ($bg_y < 0) {
208
+        //no repeat y
209
+        if ($bg_y < 0) {
210 210
         $bg_height = $img_h + $bg_y;
211
-      } else {
211
+        } else {
212 212
         $y += ($bg_y * 72)/DOMPDF_DPI;
213 213
         $bg_height = $bg_height - $bg_y;
214 214
         if ($bg_height > $img_h) {
215
-          $bg_height = $img_h;
215
+            $bg_height = $img_h;
216 216
         }
217 217
         $bg_y = 0;
218
-      }
219
-      if ($bg_height <= 0) {
220
-      	return;
221
-      }
222
-      $height = (float)($bg_height * 72)/DOMPDF_DPI;
218
+        }
219
+        if ($bg_height <= 0) {
220
+            return;
221
+        }
222
+        $height = (float)($bg_height * 72)/DOMPDF_DPI;
223 223
     } else {
224
-      //repeat y
225
-      if ($bg_y < 0) {
224
+        //repeat y
225
+        if ($bg_y < 0) {
226 226
         $bg_y = - ((-$bg_y) % $img_h);
227
-      } else {
227
+        } else {
228 228
         $bg_y = $bg_y % $img_h;
229 229
         if ($bg_y > 0) {
230
-          $bg_y -= $img_h;
230
+            $bg_y -= $img_h;
231
+        }
231 232
         }
232
-      }
233 233
     }
234 234
 
235 235
     //Optimization, if repeat has no effect
236 236
     if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) {
237
-      $repeat = "repeat-x";
237
+        $repeat = "repeat-x";
238 238
     }
239 239
     if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) {
240
-      $repeat = "repeat-y";
240
+        $repeat = "repeat-y";
241 241
     }
242 242
     if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) ||
243 243
          ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) {
244
-      $repeat = "no-repeat";
244
+        $repeat = "no-repeat";
245 245
     }
246 246
 
247
-	//Use filename as indicator only
248
-	//different names for different variants to have different copies in the pdf
249
-	//This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color)
250
-	//Note: Here, bg_* are the start values, not end values after going through the tile loops!
247
+    //Use filename as indicator only
248
+    //different names for different variants to have different copies in the pdf
249
+    //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color)
250
+    //Note: Here, bg_* are the start values, not end values after going through the tile loops!
251 251
 
252
-	$filedummy = $img;
252
+    $filedummy = $img;
253 253
 
254 254
     /* 
255 255
     //Make shorter strings with limited characters for cache associative array index - needed?	
@@ -274,50 +274,50 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 	*/
276 276
 	
277
-	$filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat;
277
+    $filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat;
278 278
     //debugpng
279 279
     //if (DEBUGPNG) print '<pre>[_background_image name '.$filedummy.']</pre>';
280 280
 
281 281
     //Optimization to avoid multiple times rendering the same image.
282 282
     //If check functions are existing and identical image already cached,
283 283
     //then skip creation of duplicate, because it is not needed by addImagePng
284
-	if ( method_exists( $this->_canvas, "get_cpdf" ) &&
285
-	     method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) &&
286
-	     method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) &&
287
-	     $this->_canvas->get_cpdf()->image_iscached($filedummy) ) {
288
-	  $bg = null;
284
+    if ( method_exists( $this->_canvas, "get_cpdf" ) &&
285
+         method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) &&
286
+         method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) &&
287
+         $this->_canvas->get_cpdf()->image_iscached($filedummy) ) {
288
+        $bg = null;
289 289
 
290
-      //debugpng
291
-      //if (DEBUGPNG) print '[_background_image skip]';
290
+        //debugpng
291
+        //if (DEBUGPNG) print '[_background_image skip]';
292 292
 
293
-	} else {
293
+    } else {
294 294
 
295 295
     // Create a new image to fit over the background rectangle
296 296
     $bg = imagecreatetruecolor($bg_width, $bg_height);
297 297
     //anyway default
298
-	//imagealphablending($img, true);
298
+    //imagealphablending($img, true);
299 299
 
300 300
     switch (strtolower($ext)) {
301 301
 
302 302
     case "png":
303 303
       $src = imagecreatefrompng($img);
304
-      break;
304
+        break;
305 305
 
306 306
     case "jpg":
307 307
     case "jpeg":
308 308
       $src = imagecreatefromjpeg($img);
309
-      break;
309
+        break;
310 310
 
311 311
     case "gif":
312 312
       $src = imagecreatefromgif($img);
313
-      break;
313
+        break;
314 314
 
315 315
     default:
316 316
       return; // Unsupported image type
317 317
     }
318 318
 
319 319
     if ($src == null) {
320
-      return;
320
+        return;
321 321
     }
322 322
 
323 323
     //Background color if box is not relevant here
@@ -325,34 +325,34 @@  discard block
 block discarded – undo
325 325
     //Transparent image: The image controls the transparency and lets shine through whatever background.
326 326
     //However on transparent imaage preset the composed image with the transparency color,
327 327
     //to keep the transparency when copying over the non transparent parts of the tiles.
328
-	$ti = imagecolortransparent($src);
329
-	if ($ti >= 0) {
330
-	  $tc = imagecolorsforindex($src,$ti);
331
-      $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']);
332
-      imagefill($bg,0,0,$ti);
333
-      imagecolortransparent($bg, $ti);
328
+    $ti = imagecolortransparent($src);
329
+    if ($ti >= 0) {
330
+        $tc = imagecolorsforindex($src,$ti);
331
+        $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']);
332
+        imagefill($bg,0,0,$ti);
333
+        imagecolortransparent($bg, $ti);
334 334
     }
335 335
 
336 336
     //This has only an effect for the non repeatable dimension.
337 337
     //compute start of src and dest coordinates of the single copy
338 338
     if ( $bg_x < 0 ) {
339
-      $dst_x = 0;
340
-      $src_x = -$bg_x;
339
+        $dst_x = 0;
340
+        $src_x = -$bg_x;
341 341
     } else {
342
-      $src_x = 0;
343
-      $dst_x = $bg_x;
342
+        $src_x = 0;
343
+        $dst_x = $bg_x;
344 344
     }
345 345
 
346 346
     if ( $bg_y < 0 ) {
347
-      $dst_y = 0;
348
-      $src_y = -$bg_y;
347
+        $dst_y = 0;
348
+        $src_y = -$bg_y;
349 349
     } else {
350
-      $src_y = 0;
351
-      $dst_y = $bg_y;
350
+        $src_y = 0;
351
+        $dst_y = $bg_y;
352 352
     }
353 353
 
354
-	//For historical reasons exchange meanings of variables:
355
-	//start_* will be the start values, while bg_* will be the temporary start values in the loops
354
+    //For historical reasons exchange meanings of variables:
355
+    //start_* will be the start values, while bg_* will be the temporary start values in the loops
356 356
     $start_x = $bg_x;
357 357
     $start_y = $bg_y;
358 358
 
@@ -360,117 +360,117 @@  discard block
 block discarded – undo
360 360
 
361 361
     if ( $repeat === "no-repeat" ) {
362 362
 
363
-      // Simply place the image on the background
364
-      imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h);
363
+        // Simply place the image on the background
364
+        imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h);
365 365
 
366 366
     } else if ( $repeat === "repeat-x" ) {
367 367
 
368
-      for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
368
+        for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
369 369
         if ( $bg_x < 0 ) {
370
-          $dst_x = 0;
371
-          $src_x = -$bg_x;
372
-          $w = $img_w + $bg_x;
370
+            $dst_x = 0;
371
+            $src_x = -$bg_x;
372
+            $w = $img_w + $bg_x;
373 373
         } else {
374
-          $dst_x = $bg_x;
375
-          $src_x = 0;
376
-          $w = $img_w;
374
+            $dst_x = $bg_x;
375
+            $src_x = 0;
376
+            $w = $img_w;
377 377
         }
378 378
         imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h);
379
-      }
379
+        }
380 380
 
381 381
     } else if ( $repeat === "repeat-y" ) {
382 382
 
383
-      for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
383
+        for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
384 384
         if ( $bg_y < 0 ) {
385
-          $dst_y = 0;
386
-          $src_y = -$bg_y;
387
-          $h = $img_h + $bg_y;
385
+            $dst_y = 0;
386
+            $src_y = -$bg_y;
387
+            $h = $img_h + $bg_y;
388 388
         } else {
389
-          $dst_y = $bg_y;
390
-          $src_y = 0;
391
-          $h = $img_h;
389
+            $dst_y = $bg_y;
390
+            $src_y = 0;
391
+            $h = $img_h;
392 392
         }
393 393
         imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $h);
394 394
 
395
-      }
395
+        }
396 396
 
397 397
     } else if ( $repeat === "repeat" ) {
398 398
 
399
-      for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
399
+        for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
400 400
         for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
401 401
 
402
-          if ( $bg_x < 0 ) {
402
+            if ( $bg_x < 0 ) {
403 403
             $dst_x = 0;
404 404
             $src_x = -$bg_x;
405 405
             $w = $img_w + $bg_x;
406
-          } else {
406
+            } else {
407 407
             $dst_x = $bg_x;
408 408
             $src_x = 0;
409 409
             $w = $img_w;
410
-          }
410
+            }
411 411
 
412
-          if ( $bg_y < 0 ) {
412
+            if ( $bg_y < 0 ) {
413 413
             $dst_y = 0;
414 414
             $src_y = -$bg_y;
415 415
             $h = $img_h + $bg_y;
416
-          } else {
416
+            } else {
417 417
             $dst_y = $bg_y;
418 418
             $src_y = 0;
419 419
             $h = $img_h;
420
-          }
421
-          imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h);
420
+            }
421
+            imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h);
422
+        }
422 423
         }
423
-      }
424 424
     } else {
425
- print 'Unknown repeat!';
425
+    print 'Unknown repeat!';
426 426
     }   
427 427
 
428 428
     } /* End optimize away creation of duplicates */
429 429
 
430 430
     //img: image url string
431
-	//img_w, img_h: original image size in px
432
-	//width, height: box size in pt
433
-	//bg_width, bg_height: box size in px
434
-	//x, y: left/top edge of box on page in pt
435
-	//start_x, start_y: placement of image relativ to pattern
436
-	//$repeat: repeat mode
437
-	//$bg: GD object of result image
438
-	//$src: GD object of original image
431
+    //img_w, img_h: original image size in px
432
+    //width, height: box size in pt
433
+    //bg_width, bg_height: box size in px
434
+    //x, y: left/top edge of box on page in pt
435
+    //start_x, start_y: placement of image relativ to pattern
436
+    //$repeat: repeat mode
437
+    //$bg: GD object of result image
438
+    //$src: GD object of original image
439 439
     //When using cpdf and optimization to direct png creation from gd object is available,
440 440
     //don't create temp file, but place gd object directly into the pdf
441
-	if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) {
442
-      //Note: CPDF_Adapter image converts y position
443
-	  $this->_canvas->get_cpdf()->addImagePng(
444
-	  		$filedummy,
445
-			$x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg);
446
-	} else {
447
-      $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png';
448
-      //debugpng
449
-      if (DEBUGPNG) print '[_background_image '.$tmp_file.']';
441
+    if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) {
442
+        //Note: CPDF_Adapter image converts y position
443
+        $this->_canvas->get_cpdf()->addImagePng(
444
+                $filedummy,
445
+            $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg);
446
+    } else {
447
+        $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png';
448
+        //debugpng
449
+        if (DEBUGPNG) print '[_background_image '.$tmp_file.']';
450 450
 
451
-      imagepng($bg, $tmp_file);
452
-      $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height);
451
+        imagepng($bg, $tmp_file);
452
+        $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height);
453 453
 
454
-      //debugpng
455
-      if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']';
454
+        //debugpng
455
+        if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']';
456 456
 
457
-      if (!DEBUGKEEPTEMP)
457
+        if (!DEBUGKEEPTEMP)
458 458
         unlink($tmp_file);
459 459
     }
460
-  }
460
+    }
461 461
 
462
-  protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
462
+    protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
463 463
     return;
464
-  }
464
+    }
465 465
   
466
-  // Border rendering functions
467
-  protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
466
+    // Border rendering functions
467
+    protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
468 468
     list($top, $right, $bottom, $left) = $widths;
469 469
 
470 470
     if ( $$side < 2 )
471
-      $dash = array($$side, 2);
471
+        $dash = array($$side, 2);
472 472
     else
473
-      $dash = array($$side);
473
+        $dash = array($$side);
474 474
   
475 475
     
476 476
     switch ($side) {
@@ -479,24 +479,24 @@  discard block
 block discarded – undo
479 479
       $delta = $top / 2;
480 480
     case "bottom":
481 481
       $delta = isset($delta) ? $delta : -$bottom / 2;
482
-      $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash);
483
-      break;
482
+        $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash);
483
+        break;
484 484
 
485 485
     case "left":
486 486
       $delta = $left / 2;
487 487
     case "right":
488 488
       $delta = isset($delta) ? $delta : - $right / 2;
489
-      $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash);
490
-      break;
489
+        $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash);
490
+        break;
491 491
 
492 492
     default:
493 493
       return;
494 494
 
495 495
     }
496
-  }
496
+    }
497 497
 
498 498
   
499
-  protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
499
+    protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
500 500
     list($top, $right, $bottom, $left) = $widths;
501 501
 
502 502
     switch ($side) {
@@ -505,24 +505,24 @@  discard block
 block discarded – undo
505 505
       $delta = $top / 2;
506 506
     case "bottom":
507 507
       $delta = isset($delta) ? $delta : -$bottom / 2;
508
-      $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side));
509
-      break;
508
+        $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side));
509
+        break;
510 510
 
511 511
     case "left":
512 512
       $delta = $left / 2;
513 513
     case "right":
514 514
       $delta = isset($delta) ? $delta : - $right / 2;
515
-      $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side));
516
-      break;
515
+        $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side));
516
+        break;
517 517
 
518 518
     default:
519 519
       return;
520 520
     }
521 521
     
522
-  }
522
+    }
523 523
 
524 524
   
525
-  protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
525
+    protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
526 526
     list($top, $right, $bottom, $left) = $widths;
527 527
 
528 528
     // All this polygon business is for beveled corners...
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
                         $x + $length - $right, $y + $top,
537 537
                         $x + $left, $y + $top);
538 538
         $this->_canvas->polygon($points, $color, null, null, true);
539
-      } else
539
+        } else
540 540
         $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
541 541
       
542
-      break;
542
+        break;
543 543
       
544 544
     case "bottom":
545 545
       if ( $corner_style === "bevel" ) {
@@ -548,10 +548,10 @@  discard block
 block discarded – undo
548 548
                         $x + $length - $right, $y - $bottom,
549 549
                         $x + $left, $y - $bottom);
550 550
         $this->_canvas->polygon($points, $color, null, null, true);
551
-      } else
551
+        } else
552 552
         $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
553 553
       
554
-      break;
554
+        break;
555 555
       
556 556
     case "left":
557 557
       if ( $corner_style === "bevel" ) {
@@ -560,10 +560,10 @@  discard block
 block discarded – undo
560 560
                         $x + $left, $y + $length - $bottom,
561 561
                         $x + $left, $y + $top);
562 562
         $this->_canvas->polygon($points, $color, null, null, true);
563
-      } else
563
+        } else
564 564
         $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
565 565
       
566
-      break;
566
+        break;
567 567
       
568 568
     case "right":
569 569
       if ( $corner_style === "bevel" ) {
@@ -572,20 +572,20 @@  discard block
 block discarded – undo
572 572
                         $x - $right, $y + $length - $bottom,
573 573
                         $x - $right, $y + $top);
574 574
         $this->_canvas->polygon($points, $color, null, null, true);
575
-      } else
575
+        } else
576 576
         $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
577 577
 
578
-      break;
578
+        break;
579 579
 
580 580
     default:
581 581
       return;
582 582
 
583 583
     }
584 584
         
585
-  }
585
+    }
586 586
 
587 587
 
588
-  protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
588
+    protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
589 589
     list($top, $right, $bottom, $left) = $widths;
590 590
     
591 591
     $line_width = $$side / 4;
@@ -612,12 +612,12 @@  discard block
 block discarded – undo
612 612
                         $x + $left, $y + $top);
613 613
         $this->_canvas->polygon($points, $color, null, null, true);
614 614
 
615
-      } else {
615
+        } else {
616 616
         $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color);
617 617
         $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color);
618 618
 
619
-      }
620
-      break;
619
+        }
620
+        break;
621 621
       
622 622
     case "bottom":
623 623
       if ( $corner_style === "bevel" ) {
@@ -636,12 +636,12 @@  discard block
 block discarded – undo
636 636
                         $x + $left, $y - $bottom);
637 637
         $this->_canvas->polygon($points, $color, null, null, true);
638 638
 
639
-      } else {
639
+        } else {
640 640
         $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color);
641 641
         $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color);
642
-      }
642
+        }
643 643
           
644
-      break;
644
+        break;
645 645
 
646 646
     case "left":
647 647
       if ( $corner_style === "bevel" ) {
@@ -660,12 +660,12 @@  discard block
 block discarded – undo
660 660
                         $x + $left, $y + $top);
661 661
         $this->_canvas->polygon($points, $color, null, null, true);
662 662
 
663
-      } else {
663
+        } else {
664 664
         $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color);
665 665
         $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color);
666
-      }
666
+        }
667 667
       
668
-      break;
668
+        break;
669 669
                       
670 670
     case "right":
671 671
       if ( $corner_style === "bevel" ) {
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         
675 675
       
676 676
         $points = array($x, $y,
677
-                      $x, $y + $length,
677
+                        $x, $y + $length,
678 678
                         $x - $line_width, $y + $length - $bottom_line_width,
679 679
                         $x - $line_width, $y + $top_line_width);
680 680
         $this->_canvas->polygon($points, $color, null, null, true);
@@ -685,21 +685,21 @@  discard block
 block discarded – undo
685 685
                         $x - $right, $y + $top);
686 686
         $this->_canvas->polygon($points, $color, null, null, true);
687 687
 
688
-      } else {
688
+        } else {
689 689
         $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color);
690 690
         $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color);
691
-      }
691
+        }
692 692
       
693
-      break;
693
+        break;
694 694
 
695 695
     default:
696 696
       return;
697 697
 
698 698
     }
699 699
         
700
-  }
700
+    }
701 701
 
702
-  protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
702
+    protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
703 703
     list($top, $right, $bottom, $left) = $widths;
704 704
       
705 705
     $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2);
@@ -710,27 +710,27 @@  discard block
 block discarded – undo
710 710
 
711 711
     case "top":
712 712
       $x += $left / 2;
713
-      $y += $top / 2;
714
-      $length -= $left / 2 + $right / 2;
715
-      break;
713
+        $y += $top / 2;
714
+        $length -= $left / 2 + $right / 2;
715
+        break;
716 716
 
717 717
     case "bottom":
718 718
       $x += $left / 2;
719
-      $y -= $bottom / 2;
720
-      $length -= $left / 2 + $right / 2;
721
-      break;
719
+        $y -= $bottom / 2;
720
+        $length -= $left / 2 + $right / 2;
721
+        break;
722 722
 
723 723
     case "left":
724 724
       $x += $left / 2;
725
-      $y += $top / 2;
726
-      $length -= $top / 2 + $bottom / 2;
727
-      break;
725
+        $y += $top / 2;
726
+        $length -= $top / 2 + $bottom / 2;
727
+        break;
728 728
 
729 729
     case "right":
730 730
       $x -= $right / 2;
731
-      $y += $top / 2;
732
-      $length -= $top / 2 + $bottom / 2;
733
-      break;
731
+        $y += $top / 2;
732
+        $length -= $top / 2 + $bottom / 2;
733
+        break;
734 734
 
735 735
     default:
736 736
       return;
@@ -739,9 +739,9 @@  discard block
 block discarded – undo
739 739
 
740 740
     $this->_border_outset($x, $y, $length, $color, $half_widths, $side);
741 741
     
742
-  }
742
+    }
743 743
   
744
-  protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
744
+    protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
745 745
     list($top, $right, $bottom, $left) = $widths;
746 746
      
747 747
     $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2);
@@ -752,27 +752,27 @@  discard block
 block discarded – undo
752 752
 
753 753
     case "top":
754 754
       $x += $left / 2;
755
-      $y += $top / 2;
756
-      $length -= $left / 2 + $right / 2;
757
-      break;
755
+        $y += $top / 2;
756
+        $length -= $left / 2 + $right / 2;
757
+        break;
758 758
 
759 759
     case "bottom":
760 760
       $x += $left / 2;
761
-      $y -= $bottom / 2;
762
-      $length -= $left / 2 + $right / 2;
763
-      break;
761
+        $y -= $bottom / 2;
762
+        $length -= $left / 2 + $right / 2;
763
+        break;
764 764
 
765 765
     case "left":
766 766
       $x += $left / 2;
767
-      $y += $top / 2;
768
-      $length -= $top / 2 + $bottom / 2;
769
-      break;
767
+        $y += $top / 2;
768
+        $length -= $top / 2 + $bottom / 2;
769
+        break;
770 770
 
771 771
     case "right":
772 772
       $x -= $right / 2;
773
-      $y += $top / 2;
774
-      $length -= $top / 2 + $bottom / 2;
775
-      break;
773
+        $y += $top / 2;
774
+        $length -= $top / 2 + $bottom / 2;
775
+        break;
776 776
 
777 777
     default:
778 778
       return;
@@ -781,23 +781,23 @@  discard block
 block discarded – undo
781 781
 
782 782
     $this->_border_inset($x, $y, $length, $color, $half_widths, $side);
783 783
 
784
-  }
784
+    }
785 785
 
786
-  protected function _tint($c) {
786
+    protected function _tint($c) {
787 787
     if ( !is_numeric($c) )
788
-      return $c;
788
+        return $c;
789 789
     
790 790
     return min(1, $c + 0.66);
791
-  }
791
+    }
792 792
 
793
-  protected function _shade($c) {
793
+    protected function _shade($c) {
794 794
     if ( !is_numeric($c) )
795
-      return $c;
795
+        return $c;
796 796
     
797 797
     return max(0, $c - 0.66);
798
-  }
798
+    }
799 799
 
800
-  protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
800
+    protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
801 801
     list($top, $right, $bottom, $left) = $widths;
802 802
     
803 803
     switch ($side) {
@@ -805,43 +805,43 @@  discard block
 block discarded – undo
805 805
     case "top":
806 806
     case "left":
807 807
       $shade = array_map(array($this, "_shade"), $color);
808
-      $this->_border_solid($x, $y, $length, $shade, $widths, $side);
809
-      break;
808
+        $this->_border_solid($x, $y, $length, $shade, $widths, $side);
809
+        break;
810 810
 
811 811
     case "bottom":
812 812
     case "right":
813 813
       $tint = array_map(array($this, "_tint"), $color);
814
-      $this->_border_solid($x, $y, $length, $tint, $widths, $side);
815
-      break;
814
+        $this->_border_solid($x, $y, $length, $tint, $widths, $side);
815
+        break;
816 816
 
817 817
     default:
818 818
       return;
819 819
     }
820
-  }
820
+    }
821 821
   
822
-  protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
822
+    protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
823 823
     list($top, $right, $bottom, $left) = $widths;
824 824
     
825 825
     switch ($side) {
826 826
     case "top":
827 827
     case "left":
828 828
       $tint = array_map(array($this, "_tint"), $color);
829
-      $this->_border_solid($x, $y, $length, $tint, $widths, $side);
830
-      break;
829
+        $this->_border_solid($x, $y, $length, $tint, $widths, $side);
830
+        break;
831 831
 
832 832
     case "bottom":
833 833
     case "right":
834 834
       $shade = array_map(array($this, "_shade"), $color);
835
-      $this->_border_solid($x, $y, $length, $shade, $widths, $side);
836
-      break;
835
+        $this->_border_solid($x, $y, $length, $shade, $widths, $side);
836
+        break;
837 837
 
838 838
     default:
839 839
       return;
840 840
 
841 841
     }
842
-  }
842
+    }
843 843
 
844
-  //........................................................................
844
+    //........................................................................
845 845
   
846 846
 
847 847
 }
Please login to merge, or discard this patch.
Switch Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -299,21 +299,21 @@  discard block
 block discarded – undo
299 299
 
300 300
     switch (strtolower($ext)) {
301 301
 
302
-    case "png":
303
-      $src = imagecreatefrompng($img);
304
-      break;
302
+        case "png":
303
+          $src = imagecreatefrompng($img);
304
+          break;
305 305
 
306
-    case "jpg":
307
-    case "jpeg":
308
-      $src = imagecreatefromjpeg($img);
309
-      break;
306
+        case "jpg":
307
+        case "jpeg":
308
+          $src = imagecreatefromjpeg($img);
309
+          break;
310 310
 
311
-    case "gif":
312
-      $src = imagecreatefromgif($img);
313
-      break;
311
+        case "gif":
312
+          $src = imagecreatefromgif($img);
313
+          break;
314 314
 
315
-    default:
316
-      return; // Unsupported image type
315
+        default:
316
+          return; // Unsupported image type
317 317
     }
318 318
 
319 319
     if ($src == null) {
@@ -475,22 +475,22 @@  discard block
 block discarded – undo
475 475
     
476 476
     switch ($side) {
477 477
 
478
-    case "top":
479
-      $delta = $top / 2;
480
-    case "bottom":
481
-      $delta = isset($delta) ? $delta : -$bottom / 2;
482
-      $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash);
483
-      break;
484
-
485
-    case "left":
486
-      $delta = $left / 2;
487
-    case "right":
488
-      $delta = isset($delta) ? $delta : - $right / 2;
489
-      $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash);
490
-      break;
491
-
492
-    default:
493
-      return;
478
+        case "top":
479
+          $delta = $top / 2;
480
+        case "bottom":
481
+          $delta = isset($delta) ? $delta : -$bottom / 2;
482
+          $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash);
483
+          break;
484
+
485
+        case "left":
486
+          $delta = $left / 2;
487
+        case "right":
488
+          $delta = isset($delta) ? $delta : - $right / 2;
489
+          $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash);
490
+          break;
491
+
492
+        default:
493
+          return;
494 494
 
495 495
     }
496 496
   }
@@ -501,22 +501,22 @@  discard block
 block discarded – undo
501 501
 
502 502
     switch ($side) {
503 503
 
504
-    case "top":
505
-      $delta = $top / 2;
506
-    case "bottom":
507
-      $delta = isset($delta) ? $delta : -$bottom / 2;
508
-      $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side));
509
-      break;
510
-
511
-    case "left":
512
-      $delta = $left / 2;
513
-    case "right":
514
-      $delta = isset($delta) ? $delta : - $right / 2;
515
-      $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side));
516
-      break;
517
-
518
-    default:
519
-      return;
504
+        case "top":
505
+          $delta = $top / 2;
506
+        case "bottom":
507
+          $delta = isset($delta) ? $delta : -$bottom / 2;
508
+          $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side));
509
+          break;
510
+
511
+        case "left":
512
+          $delta = $left / 2;
513
+        case "right":
514
+          $delta = isset($delta) ? $delta : - $right / 2;
515
+          $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side));
516
+          break;
517
+
518
+        default:
519
+          return;
520 520
     }
521 521
     
522 522
   }
@@ -528,57 +528,57 @@  discard block
 block discarded – undo
528 528
     // All this polygon business is for beveled corners...
529 529
     switch ($side) {
530 530
 
531
-    case "top":
532
-      if ( $corner_style === "bevel" ) {
531
+        case "top":
532
+          if ( $corner_style === "bevel" ) {
533 533
         
534
-        $points = array($x, $y,
535
-                        $x + $length, $y,
536
-                        $x + $length - $right, $y + $top,
537
-                        $x + $left, $y + $top);
538
-        $this->_canvas->polygon($points, $color, null, null, true);
539
-      } else
540
-        $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
534
+            $points = array($x, $y,
535
+                            $x + $length, $y,
536
+                            $x + $length - $right, $y + $top,
537
+                            $x + $left, $y + $top);
538
+            $this->_canvas->polygon($points, $color, null, null, true);
539
+          } else
540
+            $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
541 541
       
542
-      break;
542
+          break;
543 543
       
544
-    case "bottom":
545
-      if ( $corner_style === "bevel" ) {
546
-        $points = array($x, $y,
547
-                        $x + $length, $y,
548
-                        $x + $length - $right, $y - $bottom,
549
-                        $x + $left, $y - $bottom);
550
-        $this->_canvas->polygon($points, $color, null, null, true);
551
-      } else
552
-        $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
544
+        case "bottom":
545
+          if ( $corner_style === "bevel" ) {
546
+            $points = array($x, $y,
547
+                            $x + $length, $y,
548
+                            $x + $length - $right, $y - $bottom,
549
+                            $x + $left, $y - $bottom);
550
+            $this->_canvas->polygon($points, $color, null, null, true);
551
+          } else
552
+            $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
553 553
       
554
-      break;
554
+          break;
555 555
       
556
-    case "left":
557
-      if ( $corner_style === "bevel" ) {
558
-        $points = array($x, $y,
559
-                        $x, $y + $length,
560
-                        $x + $left, $y + $length - $bottom,
561
-                        $x + $left, $y + $top);
562
-        $this->_canvas->polygon($points, $color, null, null, true);
563
-      } else
564
-        $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
556
+        case "left":
557
+          if ( $corner_style === "bevel" ) {
558
+            $points = array($x, $y,
559
+                            $x, $y + $length,
560
+                            $x + $left, $y + $length - $bottom,
561
+                            $x + $left, $y + $top);
562
+            $this->_canvas->polygon($points, $color, null, null, true);
563
+          } else
564
+            $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
565 565
       
566
-      break;
566
+          break;
567 567
       
568
-    case "right":
569
-      if ( $corner_style === "bevel" ) {
570
-        $points = array($x, $y,
571
-                        $x, $y + $length,
572
-                        $x - $right, $y + $length - $bottom,
573
-                        $x - $right, $y + $top);
574
-        $this->_canvas->polygon($points, $color, null, null, true);
575
-      } else
576
-        $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
577
-
578
-      break;
579
-
580
-    default:
581
-      return;
568
+        case "right":
569
+          if ( $corner_style === "bevel" ) {
570
+            $points = array($x, $y,
571
+                            $x, $y + $length,
572
+                            $x - $right, $y + $length - $bottom,
573
+                            $x - $right, $y + $top);
574
+            $this->_canvas->polygon($points, $color, null, null, true);
575
+          } else
576
+            $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
577
+
578
+          break;
579
+
580
+        default:
581
+          return;
582 582
 
583 583
     }
584 584
         
@@ -595,105 +595,105 @@  discard block
 block discarded – undo
595 595
     // inner bottom, inner top.
596 596
     switch ($side) {
597 597
 
598
-    case "top":
599
-      if ( $corner_style === "bevel" ) {
600
-        $left_line_width = $left / 4;
601
-        $right_line_width = $right / 4;
598
+        case "top":
599
+          if ( $corner_style === "bevel" ) {
600
+            $left_line_width = $left / 4;
601
+            $right_line_width = $right / 4;
602 602
         
603
-        $points = array($x, $y,
604
-                        $x + $length, $y,
605
-                        $x + $length - $right_line_width, $y + $line_width,
606
-                        $x + $left_line_width, $y + $line_width,);
607
-        $this->_canvas->polygon($points, $color, null, null, true);
603
+            $points = array($x, $y,
604
+                            $x + $length, $y,
605
+                            $x + $length - $right_line_width, $y + $line_width,
606
+                            $x + $left_line_width, $y + $line_width,);
607
+            $this->_canvas->polygon($points, $color, null, null, true);
608 608
         
609
-        $points = array($x + $left - $left_line_width, $y + $top - $line_width,
610
-                        $x + $length - $right + $right_line_width, $y + $top - $line_width,
611
-                        $x + $length - $right, $y + $top,
612
-                        $x + $left, $y + $top);
613
-        $this->_canvas->polygon($points, $color, null, null, true);
609
+            $points = array($x + $left - $left_line_width, $y + $top - $line_width,
610
+                            $x + $length - $right + $right_line_width, $y + $top - $line_width,
611
+                            $x + $length - $right, $y + $top,
612
+                            $x + $left, $y + $top);
613
+            $this->_canvas->polygon($points, $color, null, null, true);
614 614
 
615
-      } else {
616
-        $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color);
617
-        $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color);
615
+          } else {
616
+            $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color);
617
+            $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color);
618 618
 
619
-      }
620
-      break;
619
+          }
620
+          break;
621 621
       
622
-    case "bottom":
623
-      if ( $corner_style === "bevel" ) {
624
-        $left_line_width = $left / 4;
625
-        $right_line_width = $right / 4;
622
+        case "bottom":
623
+          if ( $corner_style === "bevel" ) {
624
+            $left_line_width = $left / 4;
625
+            $right_line_width = $right / 4;
626 626
         
627
-        $points = array($x, $y,
628
-                        $x + $length, $y,
629
-                        $x + $length - $right_line_width, $y - $line_width,
630
-                        $x + $left_line_width, $y - $line_width);
631
-        $this->_canvas->polygon($points, $color, null, null, true);
627
+            $points = array($x, $y,
628
+                            $x + $length, $y,
629
+                            $x + $length - $right_line_width, $y - $line_width,
630
+                            $x + $left_line_width, $y - $line_width);
631
+            $this->_canvas->polygon($points, $color, null, null, true);
632 632
         
633
-        $points = array($x + $left - $left_line_width, $y - $bottom + $line_width,
634
-                        $x + $length - $right + $right_line_width, $y - $bottom + $line_width,
635
-                        $x + $length - $right, $y - $bottom,
636
-                        $x + $left, $y - $bottom);
637
-        $this->_canvas->polygon($points, $color, null, null, true);
633
+            $points = array($x + $left - $left_line_width, $y - $bottom + $line_width,
634
+                            $x + $length - $right + $right_line_width, $y - $bottom + $line_width,
635
+                            $x + $length - $right, $y - $bottom,
636
+                            $x + $left, $y - $bottom);
637
+            $this->_canvas->polygon($points, $color, null, null, true);
638 638
 
639
-      } else {
640
-        $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color);
641
-        $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color);
642
-      }
639
+          } else {
640
+            $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color);
641
+            $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color);
642
+          }
643 643
           
644
-      break;
644
+          break;
645 645
 
646
-    case "left":
647
-      if ( $corner_style === "bevel" ) {
648
-        $top_line_width = $top / 4;
649
-        $bottom_line_width = $bottom / 4;
646
+        case "left":
647
+          if ( $corner_style === "bevel" ) {
648
+            $top_line_width = $top / 4;
649
+            $bottom_line_width = $bottom / 4;
650 650
         
651
-        $points = array($x, $y,
652
-                        $x, $y + $length,
653
-                        $x + $line_width, $y + $length - $bottom_line_width,
654
-                        $x + $line_width, $y + $top_line_width);
655
-        $this->_canvas->polygon($points, $color, null, null, true);
656
-
657
-        $points = array($x + $left - $line_width, $y + $top - $top_line_width,
658
-                        $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width,
659
-                        $x + $left, $y + $length - $bottom,
660
-                        $x + $left, $y + $top);
661
-        $this->_canvas->polygon($points, $color, null, null, true);
651
+            $points = array($x, $y,
652
+                            $x, $y + $length,
653
+                            $x + $line_width, $y + $length - $bottom_line_width,
654
+                            $x + $line_width, $y + $top_line_width);
655
+            $this->_canvas->polygon($points, $color, null, null, true);
656
+
657
+            $points = array($x + $left - $line_width, $y + $top - $top_line_width,
658
+                            $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width,
659
+                            $x + $left, $y + $length - $bottom,
660
+                            $x + $left, $y + $top);
661
+            $this->_canvas->polygon($points, $color, null, null, true);
662 662
 
663
-      } else {
664
-        $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color);
665
-        $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color);
666
-      }
663
+          } else {
664
+            $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color);
665
+            $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color);
666
+          }
667 667
       
668
-      break;
668
+          break;
669 669
                       
670
-    case "right":
671
-      if ( $corner_style === "bevel" ) {
672
-        $top_line_width = $top / 4;
673
-        $bottom_line_width = $bottom / 4;
670
+        case "right":
671
+          if ( $corner_style === "bevel" ) {
672
+            $top_line_width = $top / 4;
673
+            $bottom_line_width = $bottom / 4;
674 674
         
675 675
       
676
-        $points = array($x, $y,
677
-                      $x, $y + $length,
678
-                        $x - $line_width, $y + $length - $bottom_line_width,
679
-                        $x - $line_width, $y + $top_line_width);
680
-        $this->_canvas->polygon($points, $color, null, null, true);
676
+            $points = array($x, $y,
677
+                          $x, $y + $length,
678
+                            $x - $line_width, $y + $length - $bottom_line_width,
679
+                            $x - $line_width, $y + $top_line_width);
680
+            $this->_canvas->polygon($points, $color, null, null, true);
681 681
         
682
-        $points = array($x - $right + $line_width, $y + $top - $top_line_width,
683
-                        $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width,
684
-                        $x - $right, $y + $length - $bottom,
685
-                        $x - $right, $y + $top);
686
-        $this->_canvas->polygon($points, $color, null, null, true);
682
+            $points = array($x - $right + $line_width, $y + $top - $top_line_width,
683
+                            $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width,
684
+                            $x - $right, $y + $length - $bottom,
685
+                            $x - $right, $y + $top);
686
+            $this->_canvas->polygon($points, $color, null, null, true);
687 687
 
688
-      } else {
689
-        $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color);
690
-        $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color);
691
-      }
688
+          } else {
689
+            $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color);
690
+            $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color);
691
+          }
692 692
       
693
-      break;
693
+          break;
694 694
 
695
-    default:
696
-      return;
695
+        default:
696
+          return;
697 697
 
698 698
     }
699 699
         
@@ -708,32 +708,32 @@  discard block
 block discarded – undo
708 708
 
709 709
     switch ($side) {
710 710
 
711
-    case "top":
712
-      $x += $left / 2;
713
-      $y += $top / 2;
714
-      $length -= $left / 2 + $right / 2;
715
-      break;
716
-
717
-    case "bottom":
718
-      $x += $left / 2;
719
-      $y -= $bottom / 2;
720
-      $length -= $left / 2 + $right / 2;
721
-      break;
722
-
723
-    case "left":
724
-      $x += $left / 2;
725
-      $y += $top / 2;
726
-      $length -= $top / 2 + $bottom / 2;
727
-      break;
728
-
729
-    case "right":
730
-      $x -= $right / 2;
731
-      $y += $top / 2;
732
-      $length -= $top / 2 + $bottom / 2;
733
-      break;
734
-
735
-    default:
736
-      return;
711
+        case "top":
712
+          $x += $left / 2;
713
+          $y += $top / 2;
714
+          $length -= $left / 2 + $right / 2;
715
+          break;
716
+
717
+        case "bottom":
718
+          $x += $left / 2;
719
+          $y -= $bottom / 2;
720
+          $length -= $left / 2 + $right / 2;
721
+          break;
722
+
723
+        case "left":
724
+          $x += $left / 2;
725
+          $y += $top / 2;
726
+          $length -= $top / 2 + $bottom / 2;
727
+          break;
728
+
729
+        case "right":
730
+          $x -= $right / 2;
731
+          $y += $top / 2;
732
+          $length -= $top / 2 + $bottom / 2;
733
+          break;
734
+
735
+        default:
736
+          return;
737 737
 
738 738
     }
739 739
 
@@ -750,32 +750,32 @@  discard block
 block discarded – undo
750 750
 
751 751
     switch ($side) {
752 752
 
753
-    case "top":
754
-      $x += $left / 2;
755
-      $y += $top / 2;
756
-      $length -= $left / 2 + $right / 2;
757
-      break;
758
-
759
-    case "bottom":
760
-      $x += $left / 2;
761
-      $y -= $bottom / 2;
762
-      $length -= $left / 2 + $right / 2;
763
-      break;
764
-
765
-    case "left":
766
-      $x += $left / 2;
767
-      $y += $top / 2;
768
-      $length -= $top / 2 + $bottom / 2;
769
-      break;
770
-
771
-    case "right":
772
-      $x -= $right / 2;
773
-      $y += $top / 2;
774
-      $length -= $top / 2 + $bottom / 2;
775
-      break;
776
-
777
-    default:
778
-      return;
753
+        case "top":
754
+          $x += $left / 2;
755
+          $y += $top / 2;
756
+          $length -= $left / 2 + $right / 2;
757
+          break;
758
+
759
+        case "bottom":
760
+          $x += $left / 2;
761
+          $y -= $bottom / 2;
762
+          $length -= $left / 2 + $right / 2;
763
+          break;
764
+
765
+        case "left":
766
+          $x += $left / 2;
767
+          $y += $top / 2;
768
+          $length -= $top / 2 + $bottom / 2;
769
+          break;
770
+
771
+        case "right":
772
+          $x -= $right / 2;
773
+          $y += $top / 2;
774
+          $length -= $top / 2 + $bottom / 2;
775
+          break;
776
+
777
+        default:
778
+          return;
779 779
 
780 780
     }
781 781
 
@@ -802,20 +802,20 @@  discard block
 block discarded – undo
802 802
     
803 803
     switch ($side) {
804 804
 
805
-    case "top":
806
-    case "left":
807
-      $shade = array_map(array($this, "_shade"), $color);
808
-      $this->_border_solid($x, $y, $length, $shade, $widths, $side);
809
-      break;
805
+        case "top":
806
+        case "left":
807
+          $shade = array_map(array($this, "_shade"), $color);
808
+          $this->_border_solid($x, $y, $length, $shade, $widths, $side);
809
+          break;
810 810
 
811
-    case "bottom":
812
-    case "right":
813
-      $tint = array_map(array($this, "_tint"), $color);
814
-      $this->_border_solid($x, $y, $length, $tint, $widths, $side);
815
-      break;
811
+        case "bottom":
812
+        case "right":
813
+          $tint = array_map(array($this, "_tint"), $color);
814
+          $this->_border_solid($x, $y, $length, $tint, $widths, $side);
815
+          break;
816 816
 
817
-    default:
818
-      return;
817
+        default:
818
+          return;
819 819
     }
820 820
   }
821 821
   
@@ -823,20 +823,20 @@  discard block
 block discarded – undo
823 823
     list($top, $right, $bottom, $left) = $widths;
824 824
     
825 825
     switch ($side) {
826
-    case "top":
827
-    case "left":
828
-      $tint = array_map(array($this, "_tint"), $color);
829
-      $this->_border_solid($x, $y, $length, $tint, $widths, $side);
830
-      break;
831
-
832
-    case "bottom":
833
-    case "right":
834
-      $shade = array_map(array($this, "_shade"), $color);
835
-      $this->_border_solid($x, $y, $length, $shade, $widths, $side);
836
-      break;
837
-
838
-    default:
839
-      return;
826
+        case "top":
827
+        case "left":
828
+          $tint = array_map(array($this, "_tint"), $color);
829
+          $this->_border_solid($x, $y, $length, $tint, $widths, $side);
830
+          break;
831
+
832
+        case "bottom":
833
+        case "right":
834
+          $shade = array_map(array($this, "_shade"), $color);
835
+          $this->_border_solid($x, $y, $length, $shade, $widths, $side);
836
+          break;
837
+
838
+        default:
839
+          return;
840 840
 
841 841
     }
842 842
   }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     $sheet = $style->get_stylesheet();
110 110
 
111 111
     // Skip degenerate cases
112
-    if ( $width == 0 || $height == 0 )
112
+    if ($width == 0 || $height == 0)
113 113
       return;
114 114
 
115 115
     //debugpng
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                                                 $sheet->get_base_path());
122 122
 
123 123
     // Bail if the image is no good
124
-    if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" )
124
+    if ($img === DOMPDF_LIB_DIR."/res/broken_image.png")
125 125
       return;
126 126
 
127 127
 	//Try to optimize away reading and composing of same background multiple times
@@ -140,35 +140,35 @@  discard block
 block discarded – undo
140 140
 
141 141
 	//Increase background resolution and dependent box size according to image resolution to be placed in
142 142
 	//Then image can be copied in without resize
143
-    $bg_width = round((float)($width * DOMPDF_DPI) / 72);
144
-    $bg_height = round((float)($height * DOMPDF_DPI) / 72);
143
+    $bg_width = round((float) ($width * DOMPDF_DPI) / 72);
144
+    $bg_height = round((float) ($height * DOMPDF_DPI) / 72);
145 145
 
146 146
     //Need %bg_x, $bg_y as background pos, where img starts, converted to pixel
147 147
 
148 148
     list($bg_x, $bg_y) = $style->background_position;
149 149
 
150
-    if ( is_percent($bg_x) ) {
150
+    if (is_percent($bg_x)) {
151 151
       // The point $bg_x % from the left edge of the image is placed
152 152
       // $bg_x % from the left edge of the background rectangle
153
-      $p = ((float)$bg_x)/100.0;
153
+      $p = ((float) $bg_x) / 100.0;
154 154
       $x1 = $p * $img_w;
155 155
       $x2 = $p * $bg_width;
156 156
 
157 157
       $bg_x = round($x2 - $x1);
158 158
     } else {
159
-      $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72);
159
+      $bg_x = round((float) ($style->length_in_pt($bg_x) * DOMPDF_DPI) / 72);
160 160
     }
161 161
 
162
-    if ( is_percent($bg_y) ) {
162
+    if (is_percent($bg_y)) {
163 163
       // The point $bg_y % from the left edge of the image is placed
164 164
       // $bg_y % from the left edge of the background rectangle
165
-      $p = ((float)$bg_y)/100.0;
165
+      $p = ((float) $bg_y) / 100.0;
166 166
       $y1 = $p * $img_h;
167 167
       $y2 = $p * $bg_height;
168 168
 
169 169
       $bg_y = round($y2 - $y1);
170 170
     } else {
171
-      $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72);
171
+      $bg_y = round((float) ($style->length_in_pt($bg_y) * DOMPDF_DPI) / 72);
172 172
     }
173 173
 
174 174
     //clip background to the image area on partial repeat. Nothing to do if img off area
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
     //On no repeat with positive offset: move size/start to have offset==0
177 177
     //Handle x/y Dimensions separately
178 178
 
179
-    if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) {
179
+    if ($repeat !== "repeat" && $repeat !== "repeat-x") {
180 180
       //No repeat x
181 181
       if ($bg_x < 0) {
182 182
         $bg_width = $img_w + $bg_x;
183 183
       } else {
184
-        $x += ($bg_x * 72)/DOMPDF_DPI;
184
+        $x += ($bg_x * 72) / DOMPDF_DPI;
185 185
         $bg_width = $bg_width - $bg_x;
186 186
         if ($bg_width > $img_w) {
187 187
           $bg_width = $img_w;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
       if ($bg_width <= 0) {
192 192
       	return;
193 193
       }
194
-      $width = (float)($bg_width * 72)/DOMPDF_DPI;
194
+      $width = (float) ($bg_width * 72) / DOMPDF_DPI;
195 195
     } else {
196 196
       //repeat x
197 197
       if ($bg_x < 0) {
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
       }
205 205
     }
206 206
 
207
-    if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) {
207
+    if ($repeat !== "repeat" && $repeat !== "repeat-y") {
208 208
       //no repeat y
209 209
       if ($bg_y < 0) {
210 210
         $bg_height = $img_h + $bg_y;
211 211
       } else {
212
-        $y += ($bg_y * 72)/DOMPDF_DPI;
212
+        $y += ($bg_y * 72) / DOMPDF_DPI;
213 213
         $bg_height = $bg_height - $bg_y;
214 214
         if ($bg_height > $img_h) {
215 215
           $bg_height = $img_h;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
       if ($bg_height <= 0) {
220 220
       	return;
221 221
       }
222
-      $height = (float)($bg_height * 72)/DOMPDF_DPI;
222
+      $height = (float) ($bg_height * 72) / DOMPDF_DPI;
223 223
     } else {
224 224
       //repeat y
225 225
       if ($bg_y < 0) {
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
     }
234 234
 
235 235
     //Optimization, if repeat has no effect
236
-    if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) {
236
+    if ($repeat === "repeat" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height) {
237 237
       $repeat = "repeat-x";
238 238
     }
239
-    if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) {
239
+    if ($repeat === "repeat" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) {
240 240
       $repeat = "repeat-y";
241 241
     }
242
-    if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) ||
243
-         ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) {
242
+    if (($repeat === "repeat-x" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) ||
243
+         ($repeat === "repeat-y" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height)) {
244 244
       $repeat = "no-repeat";
245 245
     }
246 246
 
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
     //Optimization to avoid multiple times rendering the same image.
282 282
     //If check functions are existing and identical image already cached,
283 283
     //then skip creation of duplicate, because it is not needed by addImagePng
284
-	if ( method_exists( $this->_canvas, "get_cpdf" ) &&
285
-	     method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) &&
286
-	     method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) &&
287
-	     $this->_canvas->get_cpdf()->image_iscached($filedummy) ) {
284
+	if (method_exists($this->_canvas, "get_cpdf") &&
285
+	     method_exists($this->_canvas->get_cpdf(), "addImagePng") &&
286
+	     method_exists($this->_canvas->get_cpdf(), "image_iscached") &&
287
+	     $this->_canvas->get_cpdf()->image_iscached($filedummy)) {
288 288
 	  $bg = null;
289 289
 
290 290
       //debugpng
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
     //to keep the transparency when copying over the non transparent parts of the tiles.
328 328
 	$ti = imagecolortransparent($src);
329 329
 	if ($ti >= 0) {
330
-	  $tc = imagecolorsforindex($src,$ti);
331
-      $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']);
332
-      imagefill($bg,0,0,$ti);
330
+	  $tc = imagecolorsforindex($src, $ti);
331
+      $ti = imagecolorallocate($bg, $tc['red'], $tc['green'], $tc['blue']);
332
+      imagefill($bg, 0, 0, $ti);
333 333
       imagecolortransparent($bg, $ti);
334 334
     }
335 335
 
336 336
     //This has only an effect for the non repeatable dimension.
337 337
     //compute start of src and dest coordinates of the single copy
338
-    if ( $bg_x < 0 ) {
338
+    if ($bg_x < 0) {
339 339
       $dst_x = 0;
340 340
       $src_x = -$bg_x;
341 341
     } else {
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
       $dst_x = $bg_x;
344 344
     }
345 345
 
346
-    if ( $bg_y < 0 ) {
346
+    if ($bg_y < 0) {
347 347
       $dst_y = 0;
348 348
       $src_y = -$bg_y;
349 349
     } else {
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
 
359 359
     // Copy regions from the source image to the background
360 360
 
361
-    if ( $repeat === "no-repeat" ) {
361
+    if ($repeat === "no-repeat") {
362 362
 
363 363
       // Simply place the image on the background
364 364
       imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h);
365 365
 
366
-    } else if ( $repeat === "repeat-x" ) {
366
+    } else if ($repeat === "repeat-x") {
367 367
 
368
-      for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
369
-        if ( $bg_x < 0 ) {
368
+      for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) {
369
+        if ($bg_x < 0) {
370 370
           $dst_x = 0;
371 371
           $src_x = -$bg_x;
372 372
           $w = $img_w + $bg_x;
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
         imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h);
379 379
       }
380 380
 
381
-    } else if ( $repeat === "repeat-y" ) {
381
+    } else if ($repeat === "repeat-y") {
382 382
 
383
-      for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
384
-        if ( $bg_y < 0 ) {
383
+      for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) {
384
+        if ($bg_y < 0) {
385 385
           $dst_y = 0;
386 386
           $src_y = -$bg_y;
387 387
           $h = $img_h + $bg_y;
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
 
395 395
       }
396 396
 
397
-    } else if ( $repeat === "repeat" ) {
397
+    } else if ($repeat === "repeat") {
398 398
 
399
-      for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
400
-        for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
399
+      for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) {
400
+        for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) {
401 401
 
402
-          if ( $bg_x < 0 ) {
402
+          if ($bg_x < 0) {
403 403
             $dst_x = 0;
404 404
             $src_x = -$bg_x;
405 405
             $w = $img_w + $bg_x;
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
             $w = $img_w;
410 410
           }
411 411
 
412
-          if ( $bg_y < 0 ) {
412
+          if ($bg_y < 0) {
413 413
             $dst_y = 0;
414 414
             $src_y = -$bg_y;
415 415
             $h = $img_h + $bg_y;
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	//$src: GD object of original image
439 439
     //When using cpdf and optimization to direct png creation from gd object is available,
440 440
     //don't create temp file, but place gd object directly into the pdf
441
-	if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) {
441
+	if (method_exists($this->_canvas, "get_cpdf") && method_exists($this->_canvas->get_cpdf(), "addImagePng")) {
442 442
       //Note: CPDF_Adapter image converts y position
443 443
 	  $this->_canvas->get_cpdf()->addImagePng(
444 444
 	  		$filedummy,
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
   protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
468 468
     list($top, $right, $bottom, $left) = $widths;
469 469
 
470
-    if ( $$side < 2 )
470
+    if ($$side < 2)
471 471
       $dash = array($$side, 2);
472 472
     else
473 473
       $dash = array($$side);
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
     switch ($side) {
530 530
 
531 531
     case "top":
532
-      if ( $corner_style === "bevel" ) {
532
+      if ($corner_style === "bevel") {
533 533
         
534 534
         $points = array($x, $y,
535 535
                         $x + $length, $y,
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
       break;
543 543
       
544 544
     case "bottom":
545
-      if ( $corner_style === "bevel" ) {
545
+      if ($corner_style === "bevel") {
546 546
         $points = array($x, $y,
547 547
                         $x + $length, $y,
548 548
                         $x + $length - $right, $y - $bottom,
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
       break;
555 555
       
556 556
     case "left":
557
-      if ( $corner_style === "bevel" ) {
557
+      if ($corner_style === "bevel") {
558 558
         $points = array($x, $y,
559 559
                         $x, $y + $length,
560 560
                         $x + $left, $y + $length - $bottom,
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
       break;
567 567
       
568 568
     case "right":
569
-      if ( $corner_style === "bevel" ) {
569
+      if ($corner_style === "bevel") {
570 570
         $points = array($x, $y,
571 571
                         $x, $y + $length,
572 572
                         $x - $right, $y + $length - $bottom,
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
     switch ($side) {
597 597
 
598 598
     case "top":
599
-      if ( $corner_style === "bevel" ) {
599
+      if ($corner_style === "bevel") {
600 600
         $left_line_width = $left / 4;
601 601
         $right_line_width = $right / 4;
602 602
         
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
       break;
621 621
       
622 622
     case "bottom":
623
-      if ( $corner_style === "bevel" ) {
623
+      if ($corner_style === "bevel") {
624 624
         $left_line_width = $left / 4;
625 625
         $right_line_width = $right / 4;
626 626
         
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
       break;
645 645
 
646 646
     case "left":
647
-      if ( $corner_style === "bevel" ) {
647
+      if ($corner_style === "bevel") {
648 648
         $top_line_width = $top / 4;
649 649
         $bottom_line_width = $bottom / 4;
650 650
         
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
       break;
669 669
                       
670 670
     case "right":
671
-      if ( $corner_style === "bevel" ) {
671
+      if ($corner_style === "bevel") {
672 672
         $top_line_width = $top / 4;
673 673
         $bottom_line_width = $bottom / 4;
674 674
         
@@ -784,14 +784,14 @@  discard block
 block discarded – undo
784 784
   }
785 785
 
786 786
   protected function _tint($c) {
787
-    if ( !is_numeric($c) )
787
+    if (!is_numeric($c))
788 788
       return $c;
789 789
     
790 790
     return min(1, $c + 0.66);
791 791
   }
792 792
 
793 793
   protected function _shade($c) {
794
-    if ( !is_numeric($c) )
794
+    if (!is_numeric($c))
795 795
       return $c;
796 796
     
797 797
     return max(0, $c - 0.66);
Please login to merge, or discard this patch.
Braces   +41 added lines, -25 removed lines patch added patch discarded remove patch
@@ -109,11 +109,14 @@  discard block
 block discarded – undo
109 109
     $sheet = $style->get_stylesheet();
110 110
 
111 111
     // Skip degenerate cases
112
-    if ( $width == 0 || $height == 0 )
113
-      return;
112
+    if ( $width == 0 || $height == 0 ) {
113
+          return;
114
+    }
114 115
 
115 116
     //debugpng
116
-    if (DEBUGPNG) print '[_background_image '.$url.']';
117
+    if (DEBUGPNG) {
118
+        print '[_background_image '.$url.']';
119
+    }
117 120
 
118 121
     list($img, $ext) = Image_Cache::resolve_url($url,
119 122
                                                 $sheet->get_protocol(),
@@ -121,8 +124,9 @@  discard block
 block discarded – undo
121 124
                                                 $sheet->get_base_path());
122 125
 
123 126
     // Bail if the image is no good
124
-    if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" )
125
-      return;
127
+    if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) {
128
+          return;
129
+    }
126 130
 
127 131
 	//Try to optimize away reading and composing of same background multiple times
128 132
 	//Postponing read with imagecreatefrom   ...()
@@ -446,16 +450,21 @@  discard block
 block discarded – undo
446 450
 	} else {
447 451
       $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png';
448 452
       //debugpng
449
-      if (DEBUGPNG) print '[_background_image '.$tmp_file.']';
453
+      if (DEBUGPNG) {
454
+          print '[_background_image '.$tmp_file.']';
455
+      }
450 456
 
451 457
       imagepng($bg, $tmp_file);
452 458
       $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height);
453 459
 
454 460
       //debugpng
455
-      if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']';
461
+      if (DEBUGPNG) {
462
+          print '[_background_image unlink '.$tmp_file.']';
463
+      }
456 464
 
457
-      if (!DEBUGKEEPTEMP)
458
-        unlink($tmp_file);
465
+      if (!DEBUGKEEPTEMP) {
466
+              unlink($tmp_file);
467
+      }
459 468
     }
460 469
   }
461 470
 
@@ -467,10 +476,11 @@  discard block
 block discarded – undo
467 476
   protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
468 477
     list($top, $right, $bottom, $left) = $widths;
469 478
 
470
-    if ( $$side < 2 )
471
-      $dash = array($$side, 2);
472
-    else
473
-      $dash = array($$side);
479
+    if ( $$side < 2 ) {
480
+          $dash = array($$side, 2);
481
+    } else {
482
+          $dash = array($$side);
483
+    }
474 484
   
475 485
     
476 486
     switch ($side) {
@@ -536,8 +546,9 @@  discard block
 block discarded – undo
536 546
                         $x + $length - $right, $y + $top,
537 547
                         $x + $left, $y + $top);
538 548
         $this->_canvas->polygon($points, $color, null, null, true);
539
-      } else
540
-        $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
549
+      } else {
550
+              $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
551
+      }
541 552
       
542 553
       break;
543 554
       
@@ -548,8 +559,9 @@  discard block
 block discarded – undo
548 559
                         $x + $length - $right, $y - $bottom,
549 560
                         $x + $left, $y - $bottom);
550 561
         $this->_canvas->polygon($points, $color, null, null, true);
551
-      } else
552
-        $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
562
+      } else {
563
+              $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
564
+      }
553 565
       
554 566
       break;
555 567
       
@@ -560,8 +572,9 @@  discard block
 block discarded – undo
560 572
                         $x + $left, $y + $length - $bottom,
561 573
                         $x + $left, $y + $top);
562 574
         $this->_canvas->polygon($points, $color, null, null, true);
563
-      } else
564
-        $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
575
+      } else {
576
+              $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
577
+      }
565 578
       
566 579
       break;
567 580
       
@@ -572,8 +585,9 @@  discard block
 block discarded – undo
572 585
                         $x - $right, $y + $length - $bottom,
573 586
                         $x - $right, $y + $top);
574 587
         $this->_canvas->polygon($points, $color, null, null, true);
575
-      } else
576
-        $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
588
+      } else {
589
+              $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
590
+      }
577 591
 
578 592
       break;
579 593
 
@@ -784,15 +798,17 @@  discard block
 block discarded – undo
784 798
   }
785 799
 
786 800
   protected function _tint($c) {
787
-    if ( !is_numeric($c) )
788
-      return $c;
801
+    if ( !is_numeric($c) ) {
802
+          return $c;
803
+    }
789 804
     
790 805
     return min(1, $c + 0.66);
791 806
   }
792 807
 
793 808
   protected function _shade($c) {
794
-    if ( !is_numeric($c) )
795
-      return $c;
809
+    if ( !is_numeric($c) ) {
810
+          return $c;
811
+    }
796 812
     
797 813
     return max(0, $c - 0.66);
798 814
   }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/block_frame_decorator.cls.php 5 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -106,6 +106,9 @@
 block discarded – undo
106 106
       unset($this->_lines[$i]);
107 107
   }
108 108
 
109
+  /**
110
+   * @param integer $lineno
111
+   */
109 112
   function set_line($lineno, $y = null, $w = null, $h = null) {
110 113
 
111 114
     if ( is_array($y) )
Please login to merge, or discard this patch.
Indentation   +106 added lines, -107 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: block_frame_decorator.cls.php,v $
6
- * Created on: 2004-06-02
7
- *
8
- * Copyright (c) 2004 - Benj Carson <[email protected]>
9
- *
10
- * This library is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU Lesser General Public
12
- * License as published by the Free Software Foundation; either
13
- * version 2.1 of the License, or (at your option) any later version.
14
- *
15
- * This library is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
- * Lesser General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Lesser General Public License
21
- * along with this library in the file LICENSE.LGPL; if not, write to the
22
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
- * 02111-1307 USA
24
- *
25
- * Alternatively, you may distribute this software under the terms of the
26
- * PHP License, version 3.0 or later.  A copy of this license should have
27
- * been distributed with this file in the file LICENSE.PHP .  If this is not
28
- * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
- *
30
- * The latest version of DOMPDF might be available at:
31
- * http://www.dompdf.com/
32
- *
33
- * @link http://www.dompdf.com/
34
- * @copyright 2004 Benj Carson
35
- * @author Benj Carson <[email protected]>
36
- * @package dompdf
37
-
38
- */
3
+     * DOMPDF - PHP5 HTML to PDF renderer
4
+     *
5
+     * File: $RCSfile: block_frame_decorator.cls.php,v $
6
+     * Created on: 2004-06-02
7
+     *
8
+     * Copyright (c) 2004 - Benj Carson <[email protected]>
9
+     *
10
+     * This library is free software; you can redistribute it and/or
11
+     * modify it under the terms of the GNU Lesser General Public
12
+     * License as published by the Free Software Foundation; either
13
+     * version 2.1 of the License, or (at your option) any later version.
14
+     *
15
+     * This library is distributed in the hope that it will be useful,
16
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
+     * Lesser General Public License for more details.
19
+     *
20
+     * You should have received a copy of the GNU Lesser General Public License
21
+     * along with this library in the file LICENSE.LGPL; if not, write to the
22
+     * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23
+     * 02111-1307 USA
24
+     *
25
+     * Alternatively, you may distribute this software under the terms of the
26
+     * PHP License, version 3.0 or later.  A copy of this license should have
27
+     * been distributed with this file in the file LICENSE.PHP .  If this is not
28
+     * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29
+     *
30
+     * The latest version of DOMPDF might be available at:
31
+     * http://www.dompdf.com/
32
+     *
33
+     * @link http://www.dompdf.com/
34
+     * @copyright 2004 Benj Carson
35
+     * @author Benj Carson <[email protected]>
36
+     * @package dompdf
37
+     */
39 38
 
40 39
 /* $Id: block_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -47,16 +46,16 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Block_Frame_Decorator extends Frame_Decorator {
49 48
 
50
-  const DEFAULT_COUNTER = "-dompdf-default-counter";
49
+    const DEFAULT_COUNTER = "-dompdf-default-counter";
51 50
 
52
-  protected $_lines; // array( [num] => array([frames] => array(<frame list>),
53
-                     //                 y, w, h) )
54
-  protected $_counters; // array([id] => counter_value) (for generated content)
55
-  protected $_cl;    // current line index
51
+    protected $_lines; // array( [num] => array([frames] => array(<frame list>),
52
+                        //                 y, w, h) )
53
+    protected $_counters; // array([id] => counter_value) (for generated content)
54
+    protected $_cl;    // current line index
56 55
 
57
-  //........................................................................
56
+    //........................................................................
58 57
 
59
-  function __construct(Frame $frame, DOMPDF $dompdf) {
58
+    function __construct(Frame $frame, DOMPDF $dompdf) {
60 59
     parent::__construct($frame, $dompdf);
61 60
     $this->_lines = array(array("frames" => array(),
62 61
                                 "wc" => 0,
@@ -66,11 +65,11 @@  discard block
 block discarded – undo
66 65
     $this->_counters = array(self::DEFAULT_COUNTER => 0);
67 66
     $this->_cl = 0;
68 67
 
69
-  }
68
+    }
70 69
 
71
-  //........................................................................
70
+    //........................................................................
72 71
 
73
-  function reset() {
72
+    function reset() {
74 73
     parent::reset();
75 74
     $this->_lines = array(array("frames" => array(),
76 75
                                 "wc" => 0,
@@ -79,67 +78,67 @@  discard block
 block discarded – undo
79 78
                                 "h" => 0));
80 79
     $this->_counters = array(self::DEFAULT_COUNTER => 0);
81 80
     $this->_cl = 0;
82
-  }
81
+    }
83 82
 
84
-  //........................................................................
83
+    //........................................................................
85 84
 
86
-  // Accessor methods
85
+    // Accessor methods
87 86
 
88
-  function get_current_line($i = null) {
87
+    function get_current_line($i = null) {
89 88
     $cl = $this->_lines[$this->_cl];
90 89
     if ( isset($i) )
91
-      return $cl[$i];
90
+        return $cl[$i];
92 91
     return $cl;
93
-  }
92
+    }
94 93
 
95
-  function get_lines() { return $this->_lines; }
94
+    function get_lines() { return $this->_lines; }
96 95
 
97
-  //........................................................................
96
+    //........................................................................
98 97
 
99
-  // Set methods
100
-  function set_current_line($y = null, $w = null, $h = null) {
98
+    // Set methods
99
+    function set_current_line($y = null, $w = null, $h = null) {
101 100
     $this->set_line($this->_cl, $y, $w, $h);
102
-  }
101
+    }
103 102
 
104
-  function clear_line($i) {
103
+    function clear_line($i) {
105 104
     if ( isset($this->_lines[$i]) )
106
-      unset($this->_lines[$i]);
107
-  }
105
+        unset($this->_lines[$i]);
106
+    }
108 107
 
109
-  function set_line($lineno, $y = null, $w = null, $h = null) {
108
+    function set_line($lineno, $y = null, $w = null, $h = null) {
110 109
 
111 110
     if ( is_array($y) )
112
-      extract($y);
111
+        extract($y);
113 112
 
114 113
     if (is_numeric($y))
115
-      $this->_lines[$lineno]["y"] = $y;
114
+        $this->_lines[$lineno]["y"] = $y;
116 115
 
117 116
     if (is_numeric($w))
118
-      $this->_lines[$lineno]["w"] = $w;
117
+        $this->_lines[$lineno]["w"] = $w;
119 118
 
120 119
     if (is_numeric($h))
121
-      $this->_lines[$lineno]["h"] = $h;
120
+        $this->_lines[$lineno]["h"] = $h;
122 121
 
123
-  }
122
+    }
124 123
 
125 124
 
126
-  function add_frame_to_line(Frame $frame) {
125
+    function add_frame_to_line(Frame $frame) {
127 126
 
128 127
     // Handle inline frames (which are effectively wrappers)
129 128
     if ( $frame instanceof Inline_Frame_Decorator ) {
130 129
 
131
-      // Handle line breaks
132
-      if ( $frame->get_node()->nodeName === "br" ) {
130
+        // Handle line breaks
131
+        if ( $frame->get_node()->nodeName === "br" ) {
133 132
         $this->maximize_line_height( $frame->get_style()->length_in_pt($frame->get_style()->line_height) );
134 133
         $this->add_line();
135 134
         return;
136
-      }
135
+        }
137 136
 
138
-      // Add each child of the inline frame to the line individually
139
-      foreach ($frame->get_children() as $child)
137
+        // Add each child of the inline frame to the line individually
138
+        foreach ($frame->get_children() as $child)
140 139
         $this->add_frame_to_line( $child );
141 140
 
142
-      return;
141
+        return;
143 142
     }
144 143
 
145 144
     // Trim leading text if this is an empty line.  Kinda a hack to put it here,
@@ -149,15 +148,15 @@  discard block
 block discarded – undo
149 148
          ($frame->get_style()->white_space !== "pre" ||
150 149
           $frame->get_style()->white_space !== "pre-wrap") ) {
151 150
 
152
-      $frame->set_text( ltrim($frame->get_text()) );
153
-      $frame->recalculate_width();
151
+        $frame->set_text( ltrim($frame->get_text()) );
152
+        $frame->recalculate_width();
154 153
 
155 154
     }
156 155
 
157 156
     $w = $frame->get_margin_width();
158 157
 
159 158
     if ( $w == 0 )
160
-      return;
159
+        return;
161 160
 
162 161
     // Debugging code:
163 162
     /*
@@ -177,7 +176,7 @@  discard block
 block discarded – undo
177 176
     // End debugging
178 177
 
179 178
     if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w"))
180
-      $this->add_line();
179
+        $this->add_line();
181 180
 
182 181
     $frame->position();
183 182
 
@@ -185,55 +184,55 @@  discard block
 block discarded – undo
185 184
     $this->_lines[$this->_cl]["frames"][] = $frame;
186 185
 
187 186
     if ( $frame->get_node()->nodeName === "#text")
188
-      $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
187
+        $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
189 188
 
190 189
     $this->_lines[$this->_cl]["w"] += $w;
191 190
     $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $frame->get_margin_height());
192 191
 
193
-  }
192
+    }
194 193
 
195
-  function remove_frames_from_line(Frame $frame) {
194
+    function remove_frames_from_line(Frame $frame) {
196 195
     // Search backwards through the lines for $frame
197 196
     $i = $this->_cl;
198 197
 
199 198
     while ($i >= 0) {
200
-      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
199
+        if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
201 200
         break;
202
-      $i--;
201
+        $i--;
203 202
     }
204 203
 
205 204
     if ( $j === false )
206
-      return;
205
+        return;
207 206
 
208 207
     // Remove $frame and all frames that follow
209 208
     while ($j < count($this->_lines[$i]["frames"])) {
210
-      $f = $this->_lines[$i]["frames"][$j];
211
-      unset($this->_lines[$i]["frames"][$j++]);
212
-      $this->_lines[$i]["w"] -= $f->get_margin_width();
209
+        $f = $this->_lines[$i]["frames"][$j];
210
+        unset($this->_lines[$i]["frames"][$j++]);
211
+        $this->_lines[$i]["w"] -= $f->get_margin_width();
213 212
     }
214 213
 
215 214
     // Recalculate the height of the line
216 215
     $h = 0;
217 216
     foreach ($this->_lines[$i]["frames"] as $f)
218
-      $h = max( $h, $f->get_margin_height() );
217
+        $h = max( $h, $f->get_margin_height() );
219 218
 
220 219
     $this->_lines[$i]["h"] = $h;
221 220
 
222 221
     // Remove all lines that follow
223 222
     while ($this->_cl > $i)
224
-      unset($this->_lines[ $this->_cl-- ]);
223
+        unset($this->_lines[ $this->_cl-- ]);
225 224
 
226
-  }
225
+    }
227 226
 
228
-  function increase_line_width($w) {
227
+    function increase_line_width($w) {
229 228
     $this->_lines[ $this->_cl ]["w"] += $w;
230
-  }
229
+    }
231 230
 
232
-  function maximize_line_height($val) {
231
+    function maximize_line_height($val) {
233 232
     $this->_lines[ $this->_cl ]["h"] = max($this->_lines[ $this->_cl ]["h"], $val);
234
-  }
233
+    }
235 234
 
236
-  function add_line() {
235
+    function add_line() {
237 236
 
238 237
 //     if ( $this->_lines[$this->_cl]["h"] == 0 ) //count($this->_lines[$i]["frames"]) == 0 ||
239 238
 //       return;
@@ -241,28 +240,28 @@  discard block
 block discarded – undo
241 240
     $y = $this->_lines[$this->_cl]["y"] + $this->_lines[$this->_cl]["h"];
242 241
 
243 242
     $this->_lines[ ++$this->_cl ] = array("frames" => array(),
244
-                                          "wc" => 0,
245
-                                          "y" => $y, "w" => 0, "h" => 0);
246
-  }
243
+                                            "wc" => 0,
244
+                                            "y" => $y, "w" => 0, "h" => 0);
245
+    }
247 246
 
248
-  //........................................................................
247
+    //........................................................................
249 248
 
250
-  function reset_counter($id = self::DEFAULT_COUNTER, $value = 0) {
249
+    function reset_counter($id = self::DEFAULT_COUNTER, $value = 0) {
251 250
     $this->_counters[$id] = $value;
252
-  }
251
+    }
253 252
 
254
-  function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
253
+    function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
255 254
     if ( !isset($this->_counters[$id]) )
256
-      $this->_counters[$id] = $increment;
255
+        $this->_counters[$id] = $increment;
257 256
     else
258
-      $this->_counters[$id] += $increment;
257
+        $this->_counters[$id] += $increment;
259 258
 
260
-  }
259
+    }
261 260
 
262
-  function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
261
+    function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
263 262
     $type = mb_strtolower($type);
264 263
     if ( !isset($this->_counters[$id]) )
265
-      $this->_counters[$id] = 0;
264
+        $this->_counters[$id] = 0;
266 265
 
267 266
     switch ($type) {
268 267
 
@@ -293,5 +292,5 @@  discard block
 block discarded – undo
293 292
     case "upper-greek":
294 293
       return chr($this->_counters[$id] + 912);
295 294
     }
296
-  }
295
+    }
297 296
 }
Please login to merge, or discard this patch.
Switch Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -266,32 +266,32 @@
 block discarded – undo
266 266
 
267 267
     switch ($type) {
268 268
 
269
-    default:
270
-    case "decimal":
271
-      return $this->_counters[$id];
269
+        default:
270
+        case "decimal":
271
+          return $this->_counters[$id];
272 272
 
273
-    case "decimal-leading-zero":
274
-      return str_pad($this->_counters[$id], 2, "0");
273
+        case "decimal-leading-zero":
274
+          return str_pad($this->_counters[$id], 2, "0");
275 275
 
276
-    case "lower-roman":
277
-      return dec2roman($this->_counters[$id]);
276
+        case "lower-roman":
277
+          return dec2roman($this->_counters[$id]);
278 278
 
279
-    case "upper-roman":
280
-      return mb_strtoupper(dec2roman($this->_counters[$id]));
279
+        case "upper-roman":
280
+          return mb_strtoupper(dec2roman($this->_counters[$id]));
281 281
 
282
-    case "lower-latin":
283
-    case "lower-alpha":
284
-      return chr( ($this->_counters[$id] % 26) + ord('a') - 1);
282
+        case "lower-latin":
283
+        case "lower-alpha":
284
+          return chr( ($this->_counters[$id] % 26) + ord('a') - 1);
285 285
 
286
-    case "upper-latin":
287
-    case "upper-alpha":
288
-      return chr( ($this->_counters[$id] % 26) + ord('A') - 1);
286
+        case "upper-latin":
287
+        case "upper-alpha":
288
+          return chr( ($this->_counters[$id] % 26) + ord('A') - 1);
289 289
 
290
-    case "lower-greek":
291
-      return chr($this->_counters[$id] + 944);
290
+        case "lower-greek":
291
+          return chr($this->_counters[$id] + 944);
292 292
 
293
-    case "upper-greek":
294
-      return chr($this->_counters[$id] + 912);
293
+        case "upper-greek":
294
+          return chr($this->_counters[$id] + 912);
295 295
     }
296 296
   }
297 297
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
   protected $_lines; // array( [num] => array([frames] => array(<frame list>),
53 53
                      //                 y, w, h) )
54 54
   protected $_counters; // array([id] => counter_value) (for generated content)
55
-  protected $_cl;    // current line index
55
+  protected $_cl; // current line index
56 56
 
57 57
   //........................................................................
58 58
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
   function get_current_line($i = null) {
89 89
     $cl = $this->_lines[$this->_cl];
90
-    if ( isset($i) )
90
+    if (isset($i))
91 91
       return $cl[$i];
92 92
     return $cl;
93 93
   }
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
   }
103 103
 
104 104
   function clear_line($i) {
105
-    if ( isset($this->_lines[$i]) )
105
+    if (isset($this->_lines[$i]))
106 106
       unset($this->_lines[$i]);
107 107
   }
108 108
 
109 109
   function set_line($lineno, $y = null, $w = null, $h = null) {
110 110
 
111
-    if ( is_array($y) )
111
+    if (is_array($y))
112 112
       extract($y);
113 113
 
114 114
     if (is_numeric($y))
@@ -126,37 +126,37 @@  discard block
 block discarded – undo
126 126
   function add_frame_to_line(Frame $frame) {
127 127
 
128 128
     // Handle inline frames (which are effectively wrappers)
129
-    if ( $frame instanceof Inline_Frame_Decorator ) {
129
+    if ($frame instanceof Inline_Frame_Decorator) {
130 130
 
131 131
       // Handle line breaks
132
-      if ( $frame->get_node()->nodeName === "br" ) {
133
-        $this->maximize_line_height( $frame->get_style()->length_in_pt($frame->get_style()->line_height) );
132
+      if ($frame->get_node()->nodeName === "br") {
133
+        $this->maximize_line_height($frame->get_style()->length_in_pt($frame->get_style()->line_height));
134 134
         $this->add_line();
135 135
         return;
136 136
       }
137 137
 
138 138
       // Add each child of the inline frame to the line individually
139 139
       foreach ($frame->get_children() as $child)
140
-        $this->add_frame_to_line( $child );
140
+        $this->add_frame_to_line($child);
141 141
 
142 142
       return;
143 143
     }
144 144
 
145 145
     // Trim leading text if this is an empty line.  Kinda a hack to put it here,
146 146
     // but what can you do...
147
-    if ( $this->_lines[$this->_cl]["w"] == 0 &&
147
+    if ($this->_lines[$this->_cl]["w"] == 0 &&
148 148
          $frame->get_node()->nodeName === "#text" &&
149 149
          ($frame->get_style()->white_space !== "pre" ||
150
-          $frame->get_style()->white_space !== "pre-wrap") ) {
150
+          $frame->get_style()->white_space !== "pre-wrap")) {
151 151
 
152
-      $frame->set_text( ltrim($frame->get_text()) );
152
+      $frame->set_text(ltrim($frame->get_text()));
153 153
       $frame->recalculate_width();
154 154
 
155 155
     }
156 156
 
157 157
     $w = $frame->get_margin_width();
158 158
 
159
-    if ( $w == 0 )
159
+    if ($w == 0)
160 160
       return;
161 161
 
162 162
     // Debugging code:
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
     $this->_lines[$this->_cl]["frames"][] = $frame;
186 186
 
187
-    if ( $frame->get_node()->nodeName === "#text")
187
+    if ($frame->get_node()->nodeName === "#text")
188 188
       $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
189 189
 
190 190
     $this->_lines[$this->_cl]["w"] += $w;
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
     $i = $this->_cl;
198 198
 
199 199
     while ($i >= 0) {
200
-      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
200
+      if (($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false)
201 201
         break;
202 202
       $i--;
203 203
     }
204 204
 
205
-    if ( $j === false )
205
+    if ($j === false)
206 206
       return;
207 207
 
208 208
     // Remove $frame and all frames that follow
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
     // Recalculate the height of the line
216 216
     $h = 0;
217 217
     foreach ($this->_lines[$i]["frames"] as $f)
218
-      $h = max( $h, $f->get_margin_height() );
218
+      $h = max($h, $f->get_margin_height());
219 219
 
220 220
     $this->_lines[$i]["h"] = $h;
221 221
 
222 222
     // Remove all lines that follow
223 223
     while ($this->_cl > $i)
224
-      unset($this->_lines[ $this->_cl-- ]);
224
+      unset($this->_lines[$this->_cl--]);
225 225
 
226 226
   }
227 227
 
228 228
   function increase_line_width($w) {
229
-    $this->_lines[ $this->_cl ]["w"] += $w;
229
+    $this->_lines[$this->_cl]["w"] += $w;
230 230
   }
231 231
 
232 232
   function maximize_line_height($val) {
233
-    $this->_lines[ $this->_cl ]["h"] = max($this->_lines[ $this->_cl ]["h"], $val);
233
+    $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $val);
234 234
   }
235 235
 
236 236
   function add_line() {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
     $y = $this->_lines[$this->_cl]["y"] + $this->_lines[$this->_cl]["h"];
242 242
 
243
-    $this->_lines[ ++$this->_cl ] = array("frames" => array(),
243
+    $this->_lines[ ++$this->_cl] = array("frames" => array(),
244 244
                                           "wc" => 0,
245 245
                                           "y" => $y, "w" => 0, "h" => 0);
246 246
   }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
   }
253 253
 
254 254
   function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
255
-    if ( !isset($this->_counters[$id]) )
255
+    if (!isset($this->_counters[$id]))
256 256
       $this->_counters[$id] = $increment;
257 257
     else
258 258
       $this->_counters[$id] += $increment;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
   function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
263 263
     $type = mb_strtolower($type);
264
-    if ( !isset($this->_counters[$id]) )
264
+    if (!isset($this->_counters[$id]))
265 265
       $this->_counters[$id] = 0;
266 266
 
267 267
     switch ($type) {
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 
282 282
     case "lower-latin":
283 283
     case "lower-alpha":
284
-      return chr( ($this->_counters[$id] % 26) + ord('a') - 1);
284
+      return chr(($this->_counters[$id] % 26) + ord('a') - 1);
285 285
 
286 286
     case "upper-latin":
287 287
     case "upper-alpha":
288
-      return chr( ($this->_counters[$id] % 26) + ord('A') - 1);
288
+      return chr(($this->_counters[$id] % 26) + ord('A') - 1);
289 289
 
290 290
     case "lower-greek":
291 291
       return chr($this->_counters[$id] + 944);
Please login to merge, or discard this patch.
Braces   +50 added lines, -34 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
 
88 88
   function get_current_line($i = null) {
89 89
     $cl = $this->_lines[$this->_cl];
90
-    if ( isset($i) )
91
-      return $cl[$i];
90
+    if ( isset($i) ) {
91
+          return $cl[$i];
92
+    }
92 93
     return $cl;
93 94
   }
94 95
 
@@ -102,23 +103,28 @@  discard block
 block discarded – undo
102 103
   }
103 104
 
104 105
   function clear_line($i) {
105
-    if ( isset($this->_lines[$i]) )
106
-      unset($this->_lines[$i]);
106
+    if ( isset($this->_lines[$i]) ) {
107
+          unset($this->_lines[$i]);
108
+    }
107 109
   }
108 110
 
109 111
   function set_line($lineno, $y = null, $w = null, $h = null) {
110 112
 
111
-    if ( is_array($y) )
112
-      extract($y);
113
+    if ( is_array($y) ) {
114
+          extract($y);
115
+    }
113 116
 
114
-    if (is_numeric($y))
115
-      $this->_lines[$lineno]["y"] = $y;
117
+    if (is_numeric($y)) {
118
+          $this->_lines[$lineno]["y"] = $y;
119
+    }
116 120
 
117
-    if (is_numeric($w))
118
-      $this->_lines[$lineno]["w"] = $w;
121
+    if (is_numeric($w)) {
122
+          $this->_lines[$lineno]["w"] = $w;
123
+    }
119 124
 
120
-    if (is_numeric($h))
121
-      $this->_lines[$lineno]["h"] = $h;
125
+    if (is_numeric($h)) {
126
+          $this->_lines[$lineno]["h"] = $h;
127
+    }
122 128
 
123 129
   }
124 130
 
@@ -136,8 +142,9 @@  discard block
 block discarded – undo
136 142
       }
137 143
 
138 144
       // Add each child of the inline frame to the line individually
139
-      foreach ($frame->get_children() as $child)
140
-        $this->add_frame_to_line( $child );
145
+      foreach ($frame->get_children() as $child) {
146
+              $this->add_frame_to_line( $child );
147
+      }
141 148
 
142 149
       return;
143 150
     }
@@ -156,8 +163,9 @@  discard block
 block discarded – undo
156 163
 
157 164
     $w = $frame->get_margin_width();
158 165
 
159
-    if ( $w == 0 )
160
-      return;
166
+    if ( $w == 0 ) {
167
+          return;
168
+    }
161 169
 
162 170
     // Debugging code:
163 171
     /*
@@ -176,16 +184,18 @@  discard block
 block discarded – undo
176 184
     */
177 185
     // End debugging
178 186
 
179
-    if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w"))
180
-      $this->add_line();
187
+    if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w")) {
188
+          $this->add_line();
189
+    }
181 190
 
182 191
     $frame->position();
183 192
 
184 193
 
185 194
     $this->_lines[$this->_cl]["frames"][] = $frame;
186 195
 
187
-    if ( $frame->get_node()->nodeName === "#text")
188
-      $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
196
+    if ( $frame->get_node()->nodeName === "#text") {
197
+          $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
198
+    }
189 199
 
190 200
     $this->_lines[$this->_cl]["w"] += $w;
191 201
     $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $frame->get_margin_height());
@@ -197,13 +207,15 @@  discard block
 block discarded – undo
197 207
     $i = $this->_cl;
198 208
 
199 209
     while ($i >= 0) {
200
-      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
201
-        break;
210
+      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) {
211
+              break;
212
+      }
202 213
       $i--;
203 214
     }
204 215
 
205
-    if ( $j === false )
206
-      return;
216
+    if ( $j === false ) {
217
+          return;
218
+    }
207 219
 
208 220
     // Remove $frame and all frames that follow
209 221
     while ($j < count($this->_lines[$i]["frames"])) {
@@ -214,14 +226,16 @@  discard block
 block discarded – undo
214 226
 
215 227
     // Recalculate the height of the line
216 228
     $h = 0;
217
-    foreach ($this->_lines[$i]["frames"] as $f)
218
-      $h = max( $h, $f->get_margin_height() );
229
+    foreach ($this->_lines[$i]["frames"] as $f) {
230
+          $h = max( $h, $f->get_margin_height() );
231
+    }
219 232
 
220 233
     $this->_lines[$i]["h"] = $h;
221 234
 
222 235
     // Remove all lines that follow
223
-    while ($this->_cl > $i)
224
-      unset($this->_lines[ $this->_cl-- ]);
236
+    while ($this->_cl > $i) {
237
+          unset($this->_lines[ $this->_cl-- ]);
238
+    }
225 239
 
226 240
   }
227 241
 
@@ -252,17 +266,19 @@  discard block
 block discarded – undo
252 266
   }
253 267
 
254 268
   function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
255
-    if ( !isset($this->_counters[$id]) )
256
-      $this->_counters[$id] = $increment;
257
-    else
258
-      $this->_counters[$id] += $increment;
269
+    if ( !isset($this->_counters[$id]) ) {
270
+          $this->_counters[$id] = $increment;
271
+    } else {
272
+          $this->_counters[$id] += $increment;
273
+    }
259 274
 
260 275
   }
261 276
 
262 277
   function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
263 278
     $type = mb_strtolower($type);
264
-    if ( !isset($this->_counters[$id]) )
265
-      $this->_counters[$id] = 0;
279
+    if ( !isset($this->_counters[$id]) ) {
280
+          $this->_counters[$id] = 0;
281
+    }
266 282
 
267 283
     switch ($type) {
268 284
 
Please login to merge, or discard this patch.