@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | $autoload = realpath($root.'/../vendor/autoload.php'); |
13 | 13 | |
14 | 14 | // we need the autoloader to be present |
15 | - if($autoload === false) |
|
15 | + if ($autoload === false) |
|
16 | 16 | { |
17 | 17 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
18 | 18 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | require_once $autoload; |
24 | 24 | |
25 | - if(!class_exists('\AppLocalize\Localization')) |
|
25 | + if (!class_exists('\AppLocalize\Localization')) |
|
26 | 26 | { |
27 | 27 | die( |
28 | 28 | '<b>ERROR:</b> The translation user interface requires the |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function addAttribute($parent, $name, $value) |
109 | 109 | { |
110 | - if(!$parent instanceof \DOMNode) { |
|
110 | + if (!$parent instanceof \DOMNode) { |
|
111 | 111 | throw new XMLHelper_Exception( |
112 | 112 | 'The specified parent node is not a node instance.', |
113 | 113 | sprintf('Tried adding attribute [%s].', $name), |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | if (!empty($text)) { |
231 | 231 | $fragment = $this->dom->createDocumentFragment(); |
232 | - if(!@$fragment->appendXML($text)) { |
|
232 | + if (!@$fragment->appendXML($text)) { |
|
233 | 233 | throw new XMLHelper_Exception( |
234 | 234 | 'Cannot append XML fragment', |
235 | 235 | sprintf( |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param array $attributes |
272 | 272 | * @return \DOMNode |
273 | 273 | */ |
274 | - function createRoot($name, $attributes=array()) |
|
274 | + function createRoot($name, $attributes = array()) |
|
275 | 275 | { |
276 | 276 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
277 | 277 | $this->addAttributes($root, $attributes); |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | $string = str_replace('<', 'LT_ESCAPE', $string); |
292 | 292 | $string = str_replace('>', 'GT_ESCAPE', $string); |
293 | 293 | |
294 | - $string = str_replace(' ',' ', $string); |
|
295 | - $string = str_replace('&','&', $string); |
|
294 | + $string = str_replace(' ', ' ', $string); |
|
295 | + $string = str_replace('&', '&', $string); |
|
296 | 296 | |
297 | 297 | return $string; |
298 | 298 | } |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public static function downloadXML($xml, $filename = 'download.xml') |
309 | 309 | { |
310 | - if(!headers_sent() && !self::$simulation) { |
|
311 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
310 | + if (!headers_sent() && !self::$simulation) { |
|
311 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | echo $xml; |
@@ -323,11 +323,11 @@ discard block |
||
323 | 323 | */ |
324 | 324 | public static function displayXML($xml) |
325 | 325 | { |
326 | - if(!headers_sent() && !self::$simulation) { |
|
326 | + if (!headers_sent() && !self::$simulation) { |
|
327 | 327 | header('Content-Type:text/xml; charset=utf-8'); |
328 | 328 | } |
329 | 329 | |
330 | - if(self::$simulation) { |
|
330 | + if (self::$simulation) { |
|
331 | 331 | $xml = '<pre>'.htmlspecialchars($xml).'</pre>'; |
332 | 332 | } |
333 | 333 | |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | * @param string[] $customInfo Associative array with name => value pairs for custom tags to add to the output xml |
346 | 346 | * @see buildErrorXML() |
347 | 347 | */ |
348 | - public static function displayErrorXML($code, $message, $title, $customInfo=array()) |
|
348 | + public static function displayErrorXML($code, $message, $title, $customInfo = array()) |
|
349 | 349 | { |
350 | - if(!headers_sent() && !self::$simulation) { |
|
351 | - header('HTTP/1.1 400 Bad Request: ' . $title, true, 400); |
|
350 | + if (!headers_sent() && !self::$simulation) { |
|
351 | + header('HTTP/1.1 400 Bad Request: '.$title, true, 400); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo)); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | |
357 | 357 | protected static $simulation = false; |
358 | 358 | |
359 | - public static function setSimulation($simulate=true) |
|
359 | + public static function setSimulation($simulate = true) |
|
360 | 360 | { |
361 | 361 | self::$simulation = $simulate; |
362 | 362 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @param string $title |
405 | 405 | * @return string |
406 | 406 | */ |
407 | - public static function buildErrorXML($code, $message, $title, $customInfo=array()) |
|
407 | + public static function buildErrorXML($code, $message, $title, $customInfo = array()) |
|
408 | 408 | { |
409 | 409 | $xml = new \DOMDocument('1.0', 'UTF-8'); |
410 | 410 | $xml->formatOutput = true; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | $helper->addTextTag($root, 'title', $title); |
419 | 419 | $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']); |
420 | 420 | |
421 | - foreach($customInfo as $name => $value) { |
|
421 | + foreach ($customInfo as $name => $value) { |
|
422 | 422 | $helper->addTextTag($root, $name, $value); |
423 | 423 | } |
424 | 424 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public static function string2xml(string $string) : string |
465 | 465 | { |
466 | - if(stristr($string, '<body')) |
|
466 | + if (stristr($string, '<body')) |
|
467 | 467 | { |
468 | 468 | throw new XMLHelper_Exception( |
469 | 469 | 'Cannot convert string with existing body element', |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | // capture all elements except the body tag itself |
495 | 495 | $xml = ''; |
496 | - foreach($root->childNodes as $child) { |
|
496 | + foreach ($root->childNodes as $child) { |
|
497 | 497 | $xml .= $dom->saveXML($child); |
498 | 498 | } |
499 | 499 |
@@ -95,20 +95,20 @@ discard block |
||
95 | 95 | $quoteStyle = array_shift($params); |
96 | 96 | $method = array_shift($params); |
97 | 97 | |
98 | - $call = $method . '('; |
|
98 | + $call = $method.'('; |
|
99 | 99 | |
100 | 100 | $total = count($params); |
101 | - if($total > 0) { |
|
102 | - for($i=0; $i < $total; $i++) |
|
101 | + if ($total > 0) { |
|
102 | + for ($i = 0; $i < $total; $i++) |
|
103 | 103 | { |
104 | 104 | $call .= self::phpVariable2JS($params[$i], $quoteStyle); |
105 | - if($i < ($total-1)) { |
|
105 | + if ($i < ($total - 1)) { |
|
106 | 106 | $call .= ','; |
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | - return $call . ');'; |
|
111 | + return $call.');'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public static function buildVariable(string $varName, $varValue) : string |
134 | 134 | { |
135 | - return $varName . "=" . self::phpVariable2JS($varValue) . ';'; |
|
135 | + return $varName."=".self::phpVariable2JS($varValue).';'; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param int $quoteStyle The quote style to use for strings |
145 | 145 | * @return string |
146 | 146 | */ |
147 | - public static function phpVariable2JS($variable, int $quoteStyle=self::QUOTE_STYLE_DOUBLE) : string |
|
147 | + public static function phpVariable2JS($variable, int $quoteStyle = self::QUOTE_STYLE_DOUBLE) : string |
|
148 | 148 | { |
149 | 149 | // after much profiling, this variant of the method offers |
150 | 150 | // the best performance. Repeat scalar values are cached |
@@ -152,22 +152,22 @@ discard block |
||
152 | 152 | |
153 | 153 | $type = gettype($variable); |
154 | 154 | $hash = null; |
155 | - if(is_scalar($variable) === true) |
|
155 | + if (is_scalar($variable) === true) |
|
156 | 156 | { |
157 | 157 | $hash = $variable; |
158 | 158 | |
159 | - if($hash === true) |
|
159 | + if ($hash === true) |
|
160 | 160 | { |
161 | 161 | $hash = 'true'; |
162 | 162 | } |
163 | - else if($hash === false) |
|
163 | + else if ($hash === false) |
|
164 | 164 | { |
165 | 165 | $hash = 'false'; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $hash .= '-'.$quoteStyle.'-'.$type; |
169 | 169 | |
170 | - if(isset(self::$variableCache[$hash])) { |
|
170 | + if (isset(self::$variableCache[$hash])) { |
|
171 | 171 | return self::$variableCache[$hash]; |
172 | 172 | } |
173 | 173 | } |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | $result = 'null'; |
176 | 176 | |
177 | 177 | // one gettype call is better than a strict if-else. |
178 | - switch($type) |
|
178 | + switch ($type) |
|
179 | 179 | { |
180 | 180 | case 'double': |
181 | 181 | case 'string': |
182 | 182 | $string = json_encode($variable); |
183 | 183 | |
184 | - if($string === false) |
|
184 | + if ($string === false) |
|
185 | 185 | { |
186 | 186 | $string = ''; |
187 | 187 | } |
188 | - else if($quoteStyle === self::QUOTE_STYLE_SINGLE) |
|
188 | + else if ($quoteStyle === self::QUOTE_STYLE_SINGLE) |
|
189 | 189 | { |
190 | - $string = mb_substr($string, 1, mb_strlen($string)-2); |
|
190 | + $string = mb_substr($string, 1, mb_strlen($string) - 2); |
|
191 | 191 | $string = "'".str_replace("'", "\'", $string)."'"; |
192 | 192 | } |
193 | 193 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'boolean': |
198 | - if($variable === true) { |
|
198 | + if ($variable === true) { |
|
199 | 199 | $result = 'true'; |
200 | 200 | } else { |
201 | 201 | $result = 'false'; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | // cache cacheable values |
216 | - if($hash !== null) |
|
216 | + if ($hash !== null) |
|
217 | 217 | { |
218 | 218 | self::$variableCache[$hash] = $result; |
219 | 219 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | self::$elementCounter++; |
247 | 247 | |
248 | - return self::$idPrefix . self::$elementCounter; |
|
248 | + return self::$idPrefix.self::$elementCounter; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | $contentLength = 0; |
98 | 98 | if (!empty($this->variables)) { |
99 | 99 | foreach ($this->variables as $name => $value) { |
100 | - $this->data .= '--' . $this->mimeBoundary . $this->eol; |
|
101 | - $this->data .= 'Content-Disposition: form-data; name="' . $name . '"' . $this->eol; |
|
100 | + $this->data .= '--'.$this->mimeBoundary.$this->eol; |
|
101 | + $this->data .= 'Content-Disposition: form-data; name="'.$name.'"'.$this->eol; |
|
102 | 102 | $this->data .= $this->eol; |
103 | - $this->data .= $value . $this->eol; |
|
103 | + $this->data .= $value.$this->eol; |
|
104 | 104 | |
105 | 105 | $contentLength += strlen($value); |
106 | 106 | } |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | |
109 | 109 | if (!empty($this->files)) { |
110 | 110 | foreach ($this->files as $varName => $def) { |
111 | - $this->data .= '--' . $this->mimeBoundary . $this->eol; |
|
112 | - $this->data .= 'Content-Disposition: form-data; name="' . $varName . '"; filename="' . $def['fileName'] . '"' . $this->eol; |
|
113 | - $this->data .= 'Content-Type: ' . $def['contentType'] . '; charset=' . $def['encoding']; |
|
114 | - $this->data .= $this->eol . $this->eol; |
|
115 | - $this->data .= $def['content'] . $this->eol; |
|
111 | + $this->data .= '--'.$this->mimeBoundary.$this->eol; |
|
112 | + $this->data .= 'Content-Disposition: form-data; name="'.$varName.'"; filename="'.$def['fileName'].'"'.$this->eol; |
|
113 | + $this->data .= 'Content-Type: '.$def['contentType'].'; charset='.$def['encoding']; |
|
114 | + $this->data .= $this->eol.$this->eol; |
|
115 | + $this->data .= $def['content'].$this->eol; |
|
116 | 116 | |
117 | 117 | $contentLength += strlen($def['content']); |
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | - $this->data .= "--" . $this->mimeBoundary . "--" . $this->eol . $this->eol; // finish with two eol's!! |
|
121 | + $this->data .= "--".$this->mimeBoundary."--".$this->eol.$this->eol; // finish with two eol's!! |
|
122 | 122 | |
123 | 123 | //echo '<pre>'.print_r($this->data,true).'</pre>'; |
124 | 124 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | 'http' => array( |
127 | 127 | 'method' => 'POST', |
128 | 128 | 'header' => |
129 | - 'Content-Length: ' . $contentLength . $this->eol . |
|
130 | - 'Content-Type: multipart/form-data; charset=UTF-8; boundary=' . $this->mimeBoundary . $this->eol |
|
129 | + 'Content-Length: '.$contentLength.$this->eol. |
|
130 | + 'Content-Type: multipart/form-data; charset=UTF-8; boundary='.$this->mimeBoundary.$this->eol |
|
131 | 131 | , |
132 | 132 | 'content' => $this->data |
133 | 133 | ) |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $errorMessage = error_get_last(); |
142 | 142 | throw new RequestHelper_Exception( |
143 | 143 | 'Request failed.', |
144 | - 'Request error message: ' . $errorMessage['message'] . ' in ' . $errorMessage['file'] . ':' . $errorMessage['line'], |
|
144 | + 'Request error message: '.$errorMessage['message'].' in '.$errorMessage['file'].':'.$errorMessage['line'], |
|
145 | 145 | self::ERROR_REQUEST_FAILED |
146 | 146 | ); |
147 | 147 | } |
@@ -8,9 +8,9 @@ discard block |
||
8 | 8 | * @param mixed $value |
9 | 9 | * @return \AppUtils\NumberInfo |
10 | 10 | */ |
11 | -function parseNumber($value, $forceNew=false) |
|
11 | +function parseNumber($value, $forceNew = false) |
|
12 | 12 | { |
13 | - if($value instanceof NumberInfo && $forceNew !== true) { |
|
13 | + if ($value instanceof NumberInfo && $forceNew !== true) { |
|
14 | 14 | return $value; |
15 | 15 | } |
16 | 16 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $args = func_get_args(); |
80 | 80 | |
81 | 81 | // is the localization package installed? |
82 | - if(class_exists('\AppLocalize\Localization')) |
|
82 | + if (class_exists('\AppLocalize\Localization')) |
|
83 | 83 | { |
84 | 84 | return call_user_func_array('\AppLocalize\t', $args); |
85 | 85 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function init() |
97 | 97 | { |
98 | - if(!class_exists('\AppLocalize\Localization')) { |
|
98 | + if (!class_exists('\AppLocalize\Localization')) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | 'gif' |
137 | 137 | ); |
138 | 138 | |
139 | - public function __construct($sourceFile=null, $resource=null, $type=null) |
|
139 | + public function __construct($sourceFile = null, $resource = null, $type = null) |
|
140 | 140 | { |
141 | 141 | // ensure that the GD library is installed |
142 | - if(!function_exists('imagecreate')) |
|
142 | + if (!function_exists('imagecreate')) |
|
143 | 143 | { |
144 | 144 | throw new ImageHelper_Exception( |
145 | 145 | 'The PHP GD extension is not installed or not enabled.', |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ); |
149 | 149 | } |
150 | 150 | |
151 | - if(is_resource($resource)) |
|
151 | + if (is_resource($resource)) |
|
152 | 152 | { |
153 | 153 | $this->sourceImage = $resource; |
154 | 154 | $this->type = $type; |
@@ -172,21 +172,21 @@ discard block |
||
172 | 172 | if (is_null($this->type)) { |
173 | 173 | throw new ImageHelper_Exception( |
174 | 174 | 'Error opening image', |
175 | - 'Not a valid supported image type for image ' . $this->file, |
|
175 | + 'Not a valid supported image type for image '.$this->file, |
|
176 | 176 | self::ERROR_UNSUPPORTED_IMAGE_TYPE |
177 | 177 | ); |
178 | 178 | } |
179 | 179 | |
180 | 180 | $this->info = self::getImageSize($this->file); |
181 | 181 | |
182 | - if(!$this->isVector()) |
|
182 | + if (!$this->isVector()) |
|
183 | 183 | { |
184 | - $method = 'imagecreatefrom' . $this->type; |
|
184 | + $method = 'imagecreatefrom'.$this->type; |
|
185 | 185 | $this->sourceImage = $method($this->file); |
186 | 186 | if (!$this->sourceImage) { |
187 | 187 | throw new ImageHelper_Exception( |
188 | 188 | 'Error creating new image', |
189 | - $method . ' failed', |
|
189 | + $method.' failed', |
|
190 | 190 | self::ERROR_FAILED_TO_CREATE_NEW_IMAGE |
191 | 191 | ); |
192 | 192 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $this->width = $this->info->getWidth(); |
199 | 199 | $this->height = $this->info->getHeight(); |
200 | 200 | |
201 | - if(!$this->isVector()) { |
|
201 | + if (!$this->isVector()) { |
|
202 | 202 | $this->setNewImage($this->duplicateImage($this->sourceImage, true)); |
203 | 203 | } |
204 | 204 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @param string $type The target file type when saving |
212 | 212 | * @return ImageHelper |
213 | 213 | */ |
214 | - public static function createNew($width, $height, $type='png') |
|
214 | + public static function createNew($width, $height, $type = 'png') |
|
215 | 215 | { |
216 | 216 | return self::createFromResource(imagecreatetruecolor($width, $height), 'png'); |
217 | 217 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public static function setConfig($name, $value) |
262 | 262 | { |
263 | - if(isset(self::$config[$name])) { |
|
263 | + if (isset(self::$config[$name])) { |
|
264 | 264 | self::$config[$name] = $value; |
265 | 265 | } |
266 | 266 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @param bool $enabled |
273 | 273 | */ |
274 | - public static function setAutoMemoryAdjustment($enabled=true) |
|
274 | + public static function setAutoMemoryAdjustment($enabled = true) |
|
275 | 275 | { |
276 | 276 | self::setConfig('auto-memory-adjustment', $enabled); |
277 | 277 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | public function enableAlpha() |
307 | 307 | { |
308 | - if(!$this->alpha) |
|
308 | + if (!$this->alpha) |
|
309 | 309 | { |
310 | 310 | self::addAlphaSupport($this->newImage, false); |
311 | 311 | $this->alpha = true; |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * @param number $percent |
337 | 337 | * @return ImageHelper |
338 | 338 | */ |
339 | - public function sharpen($percent=0) |
|
339 | + public function sharpen($percent = 0) |
|
340 | 340 | { |
341 | - if($percent <= 0) { |
|
341 | + if ($percent <= 0) { |
|
342 | 342 | return $this; |
343 | 343 | } |
344 | 344 | |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | return $this->convolute($factor); |
348 | 348 | } |
349 | 349 | |
350 | - public function blur($percent=0) |
|
350 | + public function blur($percent = 0) |
|
351 | 351 | { |
352 | - if($percent <= 0) { |
|
352 | + if ($percent <= 0) { |
|
353 | 353 | return $this; |
354 | 354 | } |
355 | 355 | |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | { |
363 | 363 | // get a value thats equal to 64 - abs( factor ) |
364 | 364 | // ( using min/max to limited the factor to 0 - 64 to not get out of range values ) |
365 | - $val1Adjustment = 64 - min( 64, max( 0, abs( $factor ) ) ); |
|
365 | + $val1Adjustment = 64 - min(64, max(0, abs($factor))); |
|
366 | 366 | |
367 | 367 | // the base factor for the "current" pixel depends on if we are blurring or sharpening. |
368 | 368 | // If we are blurring use 1, if sharpening use 9. |
369 | 369 | $val1Base = 9; |
370 | - if( abs( $factor ) != $factor ) { |
|
370 | + if (abs($factor) != $factor) { |
|
371 | 371 | $val1Base = 1; |
372 | 372 | } |
373 | 373 | |
@@ -380,24 +380,24 @@ discard block |
||
380 | 380 | |
381 | 381 | // the value for the surrounding pixels is either positive or negative depending on if we are blurring or sharpening. |
382 | 382 | $val2 = -1; |
383 | - if( abs( $factor ) != $factor ) { |
|
383 | + if (abs($factor) != $factor) { |
|
384 | 384 | $val2 = 1; |
385 | 385 | } |
386 | 386 | |
387 | 387 | // setup matrix .. |
388 | 388 | $matrix = array( |
389 | - array( $val2, $val2, $val2 ), |
|
390 | - array( $val2, $val1, $val2 ), |
|
391 | - array( $val2, $val2, $val2 ) |
|
389 | + array($val2, $val2, $val2), |
|
390 | + array($val2, $val1, $val2), |
|
391 | + array($val2, $val2, $val2) |
|
392 | 392 | ); |
393 | 393 | |
394 | 394 | // calculate the correct divisor |
395 | 395 | // actual divisor is equal to "$divisor = $val1 + $val2 * 8;" |
396 | 396 | // but the following line is more generic |
397 | - $divisor = array_sum( array_map( 'array_sum', $matrix ) ); |
|
397 | + $divisor = array_sum(array_map('array_sum', $matrix)); |
|
398 | 398 | |
399 | 399 | // apply the matrix |
400 | - imageconvolution( $this->newImage, $matrix, $divisor, 0 ); |
|
400 | + imageconvolution($this->newImage, $matrix, $divisor, 0); |
|
401 | 401 | |
402 | 402 | return $this; |
403 | 403 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | */ |
524 | 524 | public function resample($width = null, $height = null) : ImageHelper |
525 | 525 | { |
526 | - if($this->isVector()) { |
|
526 | + if ($this->isVector()) { |
|
527 | 527 | return $this; |
528 | 528 | } |
529 | 529 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | |
545 | 545 | public function resampleAndCrop($width, $height) : ImageHelper |
546 | 546 | { |
547 | - if($this->isVector()) { |
|
547 | + if ($this->isVector()) { |
|
548 | 548 | return $this; |
549 | 549 | } |
550 | 550 | |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | * @param resource $canvas |
592 | 592 | * @param bool $fill Whether to fill the whole canvas with the transparency |
593 | 593 | */ |
594 | - public static function addAlphaSupport($canvas, $fill=true) |
|
594 | + public static function addAlphaSupport($canvas, $fill = true) |
|
595 | 595 | { |
596 | 596 | self::requireResource($canvas); |
597 | 597 | |
598 | - imagealphablending($canvas,true); |
|
598 | + imagealphablending($canvas, true); |
|
599 | 599 | imagesavealpha($canvas, true); |
600 | 600 | |
601 | - if($fill) { |
|
601 | + if ($fill) { |
|
602 | 602 | self::fillImageTransparent($canvas); |
603 | 603 | } |
604 | 604 | } |
@@ -608,9 +608,9 @@ discard block |
||
608 | 608 | return $this->alpha; |
609 | 609 | } |
610 | 610 | |
611 | - public function save(string $targetFile, $dispose=true) |
|
611 | + public function save(string $targetFile, $dispose = true) |
|
612 | 612 | { |
613 | - if($this->isVector()) { |
|
613 | + if ($this->isVector()) { |
|
614 | 614 | return true; |
615 | 615 | } |
616 | 616 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | ); |
623 | 623 | } |
624 | 624 | |
625 | - if($this->newImage === false) { |
|
625 | + if ($this->newImage === false) { |
|
626 | 626 | throw new ImageHelper_Exception( |
627 | 627 | 'Cannot save image, not a valid image resource', |
628 | 628 | 'The image is not a resource, but boolean false', |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | unlink($targetFile); |
635 | 635 | } |
636 | 636 | |
637 | - $method = 'image' . $this->type; |
|
637 | + $method = 'image'.$this->type; |
|
638 | 638 | if (!$method($this->newImage, $targetFile, $this->resolveQuality())) { |
639 | 639 | throw new ImageHelper_Exception( |
640 | 640 | 'Error creating new image', |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | ); |
656 | 656 | } |
657 | 657 | |
658 | - if($dispose) { |
|
658 | + if ($dispose) { |
|
659 | 659 | $this->dispose(); |
660 | 660 | } |
661 | 661 | |
@@ -664,11 +664,11 @@ discard block |
||
664 | 664 | |
665 | 665 | public function dispose() |
666 | 666 | { |
667 | - if(is_resource($this->sourceImage)) { |
|
667 | + if (is_resource($this->sourceImage)) { |
|
668 | 668 | imagedestroy($this->sourceImage); |
669 | 669 | } |
670 | 670 | |
671 | - if(is_resource($this->newImage)) { |
|
671 | + if (is_resource($this->newImage)) { |
|
672 | 672 | imagedestroy($this->newImage); |
673 | 673 | } |
674 | 674 | } |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | */ |
722 | 722 | protected function adjustMemory() : bool |
723 | 723 | { |
724 | - if(!self::$config['auto-memory-adjustment']) { |
|
724 | + if (!self::$config['auto-memory-adjustment']) { |
|
725 | 725 | return true; |
726 | 726 | } |
727 | 727 | |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | if (function_exists('memory_get_usage') && memory_get_usage() + $memoryNeeded > $memoryLimit) { |
751 | 751 | $newLimit = ($memoryLimit + (memory_get_usage() + $memoryNeeded)) / $MB; |
752 | 752 | $newLimit = ceil($newLimit); |
753 | - ini_set('memory_limit', $newLimit . 'M'); |
|
753 | + ini_set('memory_limit', $newLimit.'M'); |
|
754 | 754 | |
755 | 755 | return true; |
756 | 756 | } |
@@ -781,19 +781,19 @@ discard block |
||
781 | 781 | */ |
782 | 782 | protected function resampleImage(int $newWidth, int $newHeight) : ImageHelper |
783 | 783 | { |
784 | - if($this->isVector()) { |
|
784 | + if ($this->isVector()) { |
|
785 | 785 | return $this; |
786 | 786 | } |
787 | 787 | |
788 | - if(is_null($newWidth)) { $newWidth = $this->newWidth; } |
|
789 | - if(is_null($newHeight)) { $newHeight = $this->newHeight; } |
|
788 | + if (is_null($newWidth)) { $newWidth = $this->newWidth; } |
|
789 | + if (is_null($newHeight)) { $newHeight = $this->newHeight; } |
|
790 | 790 | |
791 | - if($this->newWidth==$newWidth && $this->newHeight==$newHeight) { |
|
791 | + if ($this->newWidth == $newWidth && $this->newHeight == $newHeight) { |
|
792 | 792 | return $this; |
793 | 793 | } |
794 | 794 | |
795 | - if($newWidth < 1) { $newWidth = 1; } |
|
796 | - if($newHeight < 1) { $newHeight = 1; } |
|
795 | + if ($newWidth < 1) { $newWidth = 1; } |
|
796 | + if ($newHeight < 1) { $newHeight = 1; } |
|
797 | 797 | |
798 | 798 | $this->adjustMemory(); |
799 | 799 | |
@@ -857,11 +857,11 @@ discard block |
||
857 | 857 | * @param string $imageType The image format to send, i.e. "jpeg", "png" |
858 | 858 | * @param int $quality The quality to use for the image. This is 0-9 (0=no compression, 9=max) for PNG, and 0-100 (0=lowest, 100=highest quality) for JPG |
859 | 859 | */ |
860 | - public static function displayImageStream($resource, $imageType, $quality=-1) |
|
860 | + public static function displayImageStream($resource, $imageType, $quality = -1) |
|
861 | 861 | { |
862 | 862 | $imageType = strtolower($imageType); |
863 | 863 | |
864 | - if(!in_array($imageType, self::$streamTypes)) { |
|
864 | + if (!in_array($imageType, self::$streamTypes)) { |
|
865 | 865 | throw new ImageHelper_Exception( |
866 | 866 | 'Invalid image stream type', |
867 | 867 | sprintf( |
@@ -872,9 +872,9 @@ discard block |
||
872 | 872 | ); |
873 | 873 | } |
874 | 874 | |
875 | - header('Content-type:image/' . $imageType); |
|
875 | + header('Content-type:image/'.$imageType); |
|
876 | 876 | |
877 | - $function = 'image' . $imageType; |
|
877 | + $function = 'image'.$imageType; |
|
878 | 878 | |
879 | 879 | $function($resource, null, $quality); |
880 | 880 | |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | if (headers_sent($file, $line)) { |
893 | 893 | throw new ImageHelper_Exception( |
894 | 894 | 'Error displaying image', |
895 | - 'Headers have already been sent: in file ' . $file . ':' . $line, |
|
895 | + 'Headers have already been sent: in file '.$file.':'.$line, |
|
896 | 896 | self::ERROR_HEADERS_ALREADY_SENT |
897 | 897 | ); |
898 | 898 | } |
@@ -909,16 +909,16 @@ discard block |
||
909 | 909 | } |
910 | 910 | |
911 | 911 | $format = self::getFileImageType($imageFile); |
912 | - if($format == 'svg') { |
|
912 | + if ($format == 'svg') { |
|
913 | 913 | $format = 'svg+xml'; |
914 | 914 | } |
915 | 915 | |
916 | - $contentType = 'image/' . $format; |
|
916 | + $contentType = 'image/'.$format; |
|
917 | 917 | |
918 | 918 | header('Content-Type: '.$contentType); |
919 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s", filemtime($imageFile)) . " GMT"); |
|
919 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($imageFile))." GMT"); |
|
920 | 920 | header('Cache-Control: public'); |
921 | - header('Content-Length: ' . filesize($imageFile)); |
|
921 | + header('Content-Length: '.filesize($imageFile)); |
|
922 | 922 | |
923 | 923 | readfile($imageFile); |
924 | 924 | exit; |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | * |
938 | 938 | * @param array $color A color definition, as an associative array with red, green, and blue keys. If not specified, the color at pixel position 0,0 will be used. |
939 | 939 | */ |
940 | - public function trim($color=null) |
|
940 | + public function trim($color = null) |
|
941 | 941 | { |
942 | 942 | return $this->trimImage($this->newImage, $color); |
943 | 943 | } |
@@ -950,15 +950,15 @@ discard block |
||
950 | 950 | * @param array $color A color definition, as an associative array with red, green, blue and alpha keys. If not specified, the color at pixel position 0,0 will be used. |
951 | 951 | * @return ImageHelper |
952 | 952 | */ |
953 | - protected function trimImage($img, $color=null) : ImageHelper |
|
953 | + protected function trimImage($img, $color = null) : ImageHelper |
|
954 | 954 | { |
955 | - if($this->isVector()) { |
|
955 | + if ($this->isVector()) { |
|
956 | 956 | return $this; |
957 | 957 | } |
958 | 958 | |
959 | 959 | self::requireResource($img); |
960 | 960 | |
961 | - if(empty($color)) { |
|
961 | + if (empty($color)) { |
|
962 | 962 | $color = imagecolorat($img, 0, 0); |
963 | 963 | $color = imagecolorsforindex($img, $color); |
964 | 964 | } |
@@ -974,16 +974,16 @@ discard block |
||
974 | 974 | $ymax = null; |
975 | 975 | |
976 | 976 | // Start scanning for the edges. |
977 | - for ($iy=0; $iy<$imh; $iy++) |
|
977 | + for ($iy = 0; $iy < $imh; $iy++) |
|
978 | 978 | { |
979 | 979 | $first = true; |
980 | 980 | |
981 | - for ($ix=0; $ix<$imw; $ix++) |
|
981 | + for ($ix = 0; $ix < $imw; $ix++) |
|
982 | 982 | { |
983 | 983 | $ndx = imagecolorat($img, $ix, $iy); |
984 | 984 | $colors = imagecolorsforindex($img, $ndx); |
985 | 985 | |
986 | - if(!$this->colorsMatch($colors, $color)) |
|
986 | + if (!$this->colorsMatch($colors, $color)) |
|
987 | 987 | { |
988 | 988 | if ($xmin > $ix) { $xmin = $ix; } |
989 | 989 | if ($xmax < $ix) { $xmax = $ix; } |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | |
992 | 992 | $ymax = $iy; |
993 | 993 | |
994 | - if($first) |
|
994 | + if ($first) |
|
995 | 995 | { |
996 | 996 | $ix = $xmax; |
997 | 997 | $first = false; |
@@ -1001,18 +1001,18 @@ discard block |
||
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | // no trimming border found |
1004 | - if($ymax === null && $ymax === null) { |
|
1004 | + if ($ymax === null && $ymax === null) { |
|
1005 | 1005 | return $this; |
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | // The new width and height of the image. |
1009 | - $imw = 1+$xmax-$xmin; // Image width in pixels |
|
1010 | - $imh = 1+$ymax-$ymin; // Image height in pixels |
|
1009 | + $imw = 1 + $xmax - $xmin; // Image width in pixels |
|
1010 | + $imh = 1 + $ymax - $ymin; // Image height in pixels |
|
1011 | 1011 | |
1012 | 1012 | // Make another image to place the trimmed version in. |
1013 | 1013 | $im2 = $this->createNewImage($imw, $imh); |
1014 | 1014 | |
1015 | - if($color['alpha'] > 0) |
|
1015 | + if ($color['alpha'] > 0) |
|
1016 | 1016 | { |
1017 | 1017 | $bg2 = imagecolorallocatealpha($im2, $color['red'], $color['green'], $color['blue'], $color['alpha']); |
1018 | 1018 | imagecolortransparent($im2, $bg2); |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | |
1049 | 1049 | $this->newImage = $image; |
1050 | 1050 | $this->newWidth = imagesx($image); |
1051 | - $this->newHeight= imagesy($image); |
|
1051 | + $this->newHeight = imagesy($image); |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | /** |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | */ |
1060 | 1060 | protected static function requireResource($subject) |
1061 | 1061 | { |
1062 | - if(is_resource($subject)) { |
|
1062 | + if (is_resource($subject)) { |
|
1063 | 1063 | return; |
1064 | 1064 | } |
1065 | 1065 | |
@@ -1107,8 +1107,8 @@ discard block |
||
1107 | 1107 | protected function colorsMatch($a, $b) : bool |
1108 | 1108 | { |
1109 | 1109 | $parts = array('red', 'green', 'blue'); |
1110 | - foreach($parts as $part) { |
|
1111 | - if($a[$part] != $b[$part]) { |
|
1110 | + foreach ($parts as $part) { |
|
1111 | + if ($a[$part] != $b[$part]) { |
|
1112 | 1112 | return false; |
1113 | 1113 | } |
1114 | 1114 | } |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | return true; |
1117 | 1117 | } |
1118 | 1118 | |
1119 | - public function fillWhite($x=0, $y=0) |
|
1119 | + public function fillWhite($x = 0, $y = 0) |
|
1120 | 1120 | { |
1121 | 1121 | $this->addRGBColor('white', 255, 255, 255); |
1122 | 1122 | return $this->fill('white', $x, $y); |
@@ -1136,11 +1136,11 @@ discard block |
||
1136 | 1136 | self::requireResource($resource); |
1137 | 1137 | |
1138 | 1138 | $transparent = imagecolorallocatealpha($resource, 89, 14, 207, 127); |
1139 | - imagecolortransparent ($resource, $transparent); |
|
1139 | + imagecolortransparent($resource, $transparent); |
|
1140 | 1140 | imagefill($resource, 0, 0, $transparent); |
1141 | 1141 | } |
1142 | 1142 | |
1143 | - public function fill($colorName, $x=0, $y=0) |
|
1143 | + public function fill($colorName, $x = 0, $y = 0) |
|
1144 | 1144 | { |
1145 | 1145 | imagefill($this->newImage, $x, $y, $this->colors[$colorName]); |
1146 | 1146 | return $this; |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | return $this; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - public function textTTF($text, $size, $colorName, $x=0, $y=0, $angle=0) |
|
1157 | + public function textTTF($text, $size, $colorName, $x = 0, $y = 0, $angle = 0) |
|
1158 | 1158 | { |
1159 | 1159 | imagealphablending($this->newImage, true); |
1160 | 1160 | |
@@ -1173,11 +1173,11 @@ discard block |
||
1173 | 1173 | return $this->newImage; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - public function paste(ImageHelper $target, $xpos=0, $ypos=0, $sourceX=0, $sourceY=0) |
|
1176 | + public function paste(ImageHelper $target, $xpos = 0, $ypos = 0, $sourceX = 0, $sourceY = 0) |
|
1177 | 1177 | { |
1178 | 1178 | $img = $target->getImage(); |
1179 | 1179 | |
1180 | - if($target->isAlpha()) { |
|
1180 | + if ($target->isAlpha()) { |
|
1181 | 1181 | $this->enableAlpha(); |
1182 | 1182 | } |
1183 | 1183 | |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | * @throws ImageHelper_Exception |
1194 | 1194 | * @see ImageHelper::ERROR_CANNOT_GET_IMAGE_SIZE |
1195 | 1195 | */ |
1196 | - public function getSize($exception=true) : ImageHelper_Size |
|
1196 | + public function getSize($exception = true) : ImageHelper_Size |
|
1197 | 1197 | { |
1198 | 1198 | return self::getImageSize($this->newImage, $exception); |
1199 | 1199 | } |
@@ -1223,10 +1223,10 @@ discard block |
||
1223 | 1223 | public function fitText($text, $matchWidth) |
1224 | 1224 | { |
1225 | 1225 | $sizes = array(); |
1226 | - for($i=1; $i<=1000; $i=$i+0.1) { |
|
1226 | + for ($i = 1; $i <= 1000; $i = $i + 0.1) { |
|
1227 | 1227 | $size = $this->calcTextSize($text, $i); |
1228 | 1228 | $sizes[] = $size; |
1229 | - if($size['width'] >= $matchWidth) { |
|
1229 | + if ($size['width'] >= $matchWidth) { |
|
1230 | 1230 | break; |
1231 | 1231 | } |
1232 | 1232 | } |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | $diffLast = $last['width'] - $matchWidth; |
1239 | 1239 | $diffPrev = $matchWidth - $prev['width']; |
1240 | 1240 | |
1241 | - if($diffLast <= $diffPrev) { |
|
1241 | + if ($diffLast <= $diffPrev) { |
|
1242 | 1242 | return $last; |
1243 | 1243 | } |
1244 | 1244 | |
@@ -1266,14 +1266,14 @@ discard block |
||
1266 | 1266 | 'bottom_left_y' => $box[1], |
1267 | 1267 | 'bottom_right_x' => $box[2], |
1268 | 1268 | 'bottom_right_y' => $box[3], |
1269 | - 'width' => $right-$left, |
|
1270 | - 'height' => $bottom-$top |
|
1269 | + 'width' => $right - $left, |
|
1270 | + 'height' => $bottom - $top |
|
1271 | 1271 | ); |
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | protected function requireTTFFont() |
1275 | 1275 | { |
1276 | - if(isset($this->TTFFile)) { |
|
1276 | + if (isset($this->TTFFile)) { |
|
1277 | 1277 | return; |
1278 | 1278 | } |
1279 | 1279 | |
@@ -1307,9 +1307,9 @@ discard block |
||
1307 | 1307 | * @see ImageHelper::ERROR_SVG_SOURCE_VIEWBOX_MISSING |
1308 | 1308 | * @see ImageHelper::ERROR_SVG_VIEWBOX_INVALID |
1309 | 1309 | */ |
1310 | - public static function getImageSize($pathOrResource, $exception=true) : ImageHelper_Size |
|
1310 | + public static function getImageSize($pathOrResource, $exception = true) : ImageHelper_Size |
|
1311 | 1311 | { |
1312 | - if(is_resource($pathOrResource)) |
|
1312 | + if (is_resource($pathOrResource)) |
|
1313 | 1313 | { |
1314 | 1314 | return new ImageHelper_Size(array( |
1315 | 1315 | 'width' => imagesx($pathOrResource), |
@@ -1323,7 +1323,7 @@ discard block |
||
1323 | 1323 | |
1324 | 1324 | $info = false; |
1325 | 1325 | $method = 'getImageSize_'.$type; |
1326 | - if(method_exists(__CLASS__, $method)) |
|
1326 | + if (method_exists(__CLASS__, $method)) |
|
1327 | 1327 | { |
1328 | 1328 | $info = call_user_func(array(__CLASS__, $method), $pathOrResource); |
1329 | 1329 | } |
@@ -1332,8 +1332,8 @@ discard block |
||
1332 | 1332 | $info = getimagesize($pathOrResource); |
1333 | 1333 | } |
1334 | 1334 | |
1335 | - if($info === false) { |
|
1336 | - if($exception) { |
|
1335 | + if ($info === false) { |
|
1336 | + if ($exception) { |
|
1337 | 1337 | throw new ImageHelper_Exception( |
1338 | 1338 | 'Error opening image file', |
1339 | 1339 | sprintf( |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | $xml = XMLHelper::createSimplexml(); |
1356 | 1356 | $xml->loadFile($imagePath); |
1357 | 1357 | |
1358 | - if($xml->hasErrors()) { |
|
1358 | + if ($xml->hasErrors()) { |
|
1359 | 1359 | throw new ImageHelper_Exception( |
1360 | 1360 | 'Error opening SVG image', |
1361 | 1361 | sprintf( |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | $xml->dispose(); |
1371 | 1371 | unset($xml); |
1372 | 1372 | |
1373 | - if(!isset($data['@attributes']) || !isset($data['@attributes']['viewBox'])) { |
|
1373 | + if (!isset($data['@attributes']) || !isset($data['@attributes']['viewBox'])) { |
|
1374 | 1374 | throw new ImageHelper_Exception( |
1375 | 1375 | 'SVG Image is corrupted', |
1376 | 1376 | sprintf( |
@@ -1386,7 +1386,7 @@ discard block |
||
1386 | 1386 | |
1387 | 1387 | $viewBox = str_replace(' ', ',', $data['@attributes']['viewBox']); |
1388 | 1388 | $viewBox = explode(',', $viewBox); |
1389 | - if(count($viewBox) != 4) { |
|
1389 | + if (count($viewBox) != 4) { |
|
1390 | 1390 | throw new ImageHelper_Exception( |
1391 | 1391 | 'SVG image has an invalid viewBox attribute', |
1392 | 1392 | sprintf( |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | * @param integer $y |
1432 | 1432 | * @return ImageHelper |
1433 | 1433 | */ |
1434 | - public function crop($width, $height, $x=0, $y=0) |
|
1434 | + public function crop($width, $height, $x = 0, $y = 0) |
|
1435 | 1435 | { |
1436 | 1436 | $new = $this->createNewImage($width, $height); |
1437 | 1437 | |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | * |
1460 | 1460 | * @return array |
1461 | 1461 | */ |
1462 | - public function calcAverageColor($format=self::COLORFORMAT_RGB) |
|
1462 | + public function calcAverageColor($format = self::COLORFORMAT_RGB) |
|
1463 | 1463 | { |
1464 | 1464 | $image = $this->duplicate(); |
1465 | 1465 | $image->resample(1, 1); |
@@ -1488,9 +1488,9 @@ discard block |
||
1488 | 1488 | * @param int $y |
1489 | 1489 | * @return array |
1490 | 1490 | */ |
1491 | - public function getColorAt($x, $y, $format=self::COLORFORMAT_RGB) |
|
1491 | + public function getColorAt($x, $y, $format = self::COLORFORMAT_RGB) |
|
1492 | 1492 | { |
1493 | - if($x > $this->getWidth() || $y > $this->getHeight()) { |
|
1493 | + if ($x > $this->getWidth() || $y > $this->getHeight()) { |
|
1494 | 1494 | throw new ImageHelper_Exception( |
1495 | 1495 | 'Position out of bounds', |
1496 | 1496 | sprintf( |
@@ -1507,7 +1507,7 @@ discard block |
||
1507 | 1507 | $idx = imagecolorat($this->newImage, $x, $y); |
1508 | 1508 | $rgb = imagecolorsforindex($this->newImage, $idx); |
1509 | 1509 | |
1510 | - if($format == self::COLORFORMAT_HEX) { |
|
1510 | + if ($format == self::COLORFORMAT_HEX) { |
|
1511 | 1511 | return self::rgb2hex($rgb); |
1512 | 1512 | } |
1513 | 1513 | |
@@ -1522,7 +1522,7 @@ discard block |
||
1522 | 1522 | */ |
1523 | 1523 | public static function rgb2luma($rgb) |
1524 | 1524 | { |
1525 | - return (($rgb['red']*2)+$rgb['blue']+($rgb['green']*3))/6; |
|
1525 | + return (($rgb['red'] * 2) + $rgb['blue'] + ($rgb['green'] * 3)) / 6; |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $this->isWindows = substr(PHP_OS, 0, 3) == 'WIN'; |
67 | 67 | |
68 | - if($this->isWindows) { |
|
68 | + if ($this->isWindows) { |
|
69 | 69 | $this->normalize['from'] = '/'; |
70 | 70 | $this->normalize['to'] = '\\'; |
71 | 71 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // |
81 | 81 | // NOTE: In case of symlinks, this resolves the symlink to its source (WIN/NIX) |
82 | 82 | $realPath = realpath($this->sourcePath); |
83 | - if(!is_dir($realPath)) { |
|
83 | + if (!is_dir($realPath)) { |
|
84 | 84 | throw new SVNHelper_Exception( |
85 | 85 | 'Local repository path does not exist', |
86 | 86 | sprintf( |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $result = array(); |
99 | 99 | preg_match_all('%([^:]+):(.+)@(https|http|svn)://(.+)%sm', $repURL, $result, PREG_PATTERN_ORDER); |
100 | 100 | |
101 | - if(!isset($result[1]) || !isset($result[1][0])) { |
|
101 | + if (!isset($result[1]) || !isset($result[1][0])) { |
|
102 | 102 | throw new SVNHelper_Exception( |
103 | 103 | 'Invalid SVN repository URL', |
104 | 104 | 'The SVN URL must have the following format: [username:password@http://domain.com/path/to/rep].', |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | * @throws SVNHelper_Exception |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function normalizePath($path, $relativize=false) |
|
134 | + public function normalizePath($path, $relativize = false) |
|
135 | 135 | { |
136 | - if(empty($path)) { |
|
136 | + if (empty($path)) { |
|
137 | 137 | return ''; |
138 | 138 | } |
139 | 139 | |
140 | - if($relativize) |
|
140 | + if ($relativize) |
|
141 | 141 | { |
142 | 142 | $path = $this->normalizePath($path); |
143 | 143 | |
144 | 144 | // path is absolute, and does not match the realpath or the source path? |
145 | - if(strstr($path, ':'.$this->getSlash()) && (!stristr($path, $this->path) && !stristr($path, $this->sourcePath))) { |
|
145 | + if (strstr($path, ':'.$this->getSlash()) && (!stristr($path, $this->path) && !stristr($path, $this->sourcePath))) { |
|
146 | 146 | throw new SVNHelper_Exception( |
147 | 147 | 'Cannot relativize path outside of repository', |
148 | 148 | sprintf( |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | */ |
224 | 224 | protected function filterPath($path) |
225 | 225 | { |
226 | - if(empty($path)) { |
|
226 | + if (empty($path)) { |
|
227 | 227 | return ''; |
228 | 228 | } |
229 | 229 | |
230 | 230 | $path = $this->getPath().'/'.$this->relativizePath($path); |
231 | 231 | |
232 | 232 | $real = realpath($path); |
233 | - if($real !== false) { |
|
233 | + if ($real !== false) { |
|
234 | 234 | return $real; |
235 | 235 | } |
236 | 236 | |
@@ -257,13 +257,13 @@ discard block |
||
257 | 257 | $key = $type.':'.$relativePath; |
258 | 258 | |
259 | 259 | $relativePath = $this->normalizePath($relativePath, true); |
260 | - if(isset($this->targets[$key])) { |
|
260 | + if (isset($this->targets[$key])) { |
|
261 | 261 | return $this->targets[$key]; |
262 | 262 | } |
263 | 263 | |
264 | 264 | $target = null; |
265 | 265 | |
266 | - switch($type) |
|
266 | + switch ($type) |
|
267 | 267 | { |
268 | 268 | case 'File': |
269 | 269 | $target = new SVNHelper_Target_File($this, $relativePath); |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function addFolder($path) |
398 | 398 | { |
399 | - if(is_dir($path)) { |
|
399 | + if (is_dir($path)) { |
|
400 | 400 | return $this->getFolder($path); |
401 | 401 | } |
402 | 402 | |
@@ -404,12 +404,12 @@ discard block |
||
404 | 404 | $tokens = explode($this->getSlash(), $path); |
405 | 405 | |
406 | 406 | $target = $this->path; |
407 | - foreach($tokens as $folder) |
|
407 | + foreach ($tokens as $folder) |
|
408 | 408 | { |
409 | 409 | $target .= $this->getSlash().$folder; |
410 | - if(file_exists($target)) |
|
410 | + if (file_exists($target)) |
|
411 | 411 | { |
412 | - if(!is_dir($target)) { |
|
412 | + if (!is_dir($target)) { |
|
413 | 413 | throw new SVNHelper_Exception( |
414 | 414 | 'Target folder is a file', |
415 | 415 | sprintf( |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | continue; |
424 | 424 | } |
425 | 425 | |
426 | - if(!mkdir($target, 0777)) { |
|
426 | + if (!mkdir($target, 0777)) { |
|
427 | 427 | throw new SVNHelper_Exception( |
428 | 428 | 'Cannot create folder', |
429 | 429 | sprintf( |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | */ |
454 | 454 | public static function setLogCallback($callback) |
455 | 455 | { |
456 | - if(!is_callable($callback)) { |
|
456 | + if (!is_callable($callback)) { |
|
457 | 457 | throw new SVNHelper_Exception( |
458 | 458 | 'Not a valid logging callback', |
459 | 459 | 'The specified argument is not callable.', |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | public static function log($message) |
468 | 468 | { |
469 | - if(isset(self::$logCallback)) { |
|
469 | + if (isset(self::$logCallback)) { |
|
470 | 470 | call_user_func(self::$logCallback, 'SVNHelper | '.$message); |
471 | 471 | } |
472 | 472 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | protected $logging = true; |
19 | 19 | |
20 | - public function __construct($message, $details=null, $code=null, $previous=null) |
|
20 | + public function __construct($message, $details = null, $code = null, $previous = null) |
|
21 | 21 | { |
22 | 22 | parent::__construct($message, $details, $code, $previous); |
23 | 23 | |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | |
32 | 32 | public function __destruct() |
33 | 33 | { |
34 | - if(!$this->logging) { |
|
34 | + if (!$this->logging) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $loggers = SVNHelper::getExceptionLoggers(); |
39 | 39 | |
40 | - if(empty($loggers)) { |
|
40 | + if (empty($loggers)) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
44 | - foreach($loggers as $callback) { |
|
44 | + foreach ($loggers as $callback) { |
|
45 | 45 | call_user_func($callback, $this); |
46 | 46 | } |
47 | 47 | } |
@@ -101,7 +101,7 @@ |
||
101 | 101 | public function hasAnyErrorCode($codes) |
102 | 102 | { |
103 | 103 | $items = array(); |
104 | - foreach($codes as $code) { |
|
104 | + foreach ($codes as $code) { |
|
105 | 105 | $items[] = ltrim($code, 'e'); |
106 | 106 | } |
107 | 107 |