@@ -12,7 +12,7 @@ |
||
| 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 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getNextPage() : int |
| 115 | 115 | { |
| 116 | - if($this->next === 0) { |
|
| 116 | + if ($this->next === 0) { |
|
| 117 | 117 | return $this->last; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function getPreviousPage() : int |
| 139 | 139 | { |
| 140 | - if($this->prev === 0) { |
|
| 140 | + if ($this->prev === 0) { |
|
| 141 | 141 | return 1; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | // adjust the adjacent value if it exceeds the |
| 183 | 183 | // total amount of pages |
| 184 | 184 | $adjacentTotal = ($adjacent * 2) + 1; |
| 185 | - if($adjacentTotal > $this->last) |
|
| 185 | + if ($adjacentTotal > $this->last) |
|
| 186 | 186 | { |
| 187 | 187 | $adjacent = (int)floor($this->last / 2); |
| 188 | 188 | } |
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | $back = 0; |
| 196 | 196 | $fwd = 0; |
| 197 | 197 | |
| 198 | - if($maxBack >= $adjacent) { |
|
| 198 | + if ($maxBack >= $adjacent) { |
|
| 199 | 199 | $back = $adjacent; |
| 200 | 200 | } else { |
| 201 | 201 | $back = $maxBack; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if($maxFwd >= $adjacent) { |
|
| 204 | + if ($maxFwd >= $adjacent) { |
|
| 205 | 205 | $fwd = $adjacent; |
| 206 | 206 | } else { |
| 207 | 207 | $fwd = $maxFwd; |
@@ -217,16 +217,16 @@ discard block |
||
| 217 | 217 | $fwd += $backDiff; |
| 218 | 218 | $back += $fwdDiff; |
| 219 | 219 | |
| 220 | - if($fwd > $maxFwd) { $fwd = $maxFwd; } |
|
| 221 | - if($back > $maxBack) { $back = $maxBack; } |
|
| 220 | + if ($fwd > $maxFwd) { $fwd = $maxFwd; } |
|
| 221 | + if ($back > $maxBack) { $back = $maxBack; } |
|
| 222 | 222 | |
| 223 | 223 | // calculate the first and last page in the list |
| 224 | 224 | $prev = $this->current - $back; |
| 225 | 225 | $next = $this->current + $fwd; |
| 226 | 226 | |
| 227 | 227 | // failsafe so we stay within the bounds |
| 228 | - if($prev < 1) { $prev = 1; } |
|
| 229 | - if($next > $this->last) { $next = $this->last; } |
|
| 228 | + if ($prev < 1) { $prev = 1; } |
|
| 229 | + if ($next > $this->last) { $next = $this->last; } |
|
| 230 | 230 | |
| 231 | 231 | // create and return the page numbers list |
| 232 | 232 | $numbers = range($prev, $next); |
@@ -319,11 +319,11 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | $pages = (int)ceil($this->total / $this->perPage); |
| 321 | 321 | |
| 322 | - if($this->current < 1) |
|
| 322 | + if ($this->current < 1) |
|
| 323 | 323 | { |
| 324 | 324 | $this->current = 1; |
| 325 | 325 | } |
| 326 | - else if($this->current > $pages) |
|
| 326 | + else if ($this->current > $pages) |
|
| 327 | 327 | { |
| 328 | 328 | $this->current = $pages; |
| 329 | 329 | } |
@@ -331,19 +331,19 @@ discard block |
||
| 331 | 331 | $this->last = $pages; |
| 332 | 332 | |
| 333 | 333 | $nextPage = $this->current + 1; |
| 334 | - if($nextPage <= $pages) { |
|
| 334 | + if ($nextPage <= $pages) { |
|
| 335 | 335 | $this->next = $nextPage; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | $prevPage = $this->current - 1; |
| 339 | - if($prevPage > 0) { |
|
| 339 | + if ($prevPage > 0) { |
|
| 340 | 340 | $this->prev = $prevPage; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | $this->offsetStart = ($this->current - 1) * $this->perPage; |
| 344 | 344 | |
| 345 | 345 | $this->offsetEnd = $this->offsetStart + $this->perPage; |
| 346 | - if($this->offsetEnd > ($this->total - 1)) { |
|
| 346 | + if ($this->offsetEnd > ($this->total - 1)) { |
|
| 347 | 347 | $this->offsetEnd = ($this->total - 1); |
| 348 | 348 | } |
| 349 | 349 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param int $code |
| 32 | 32 | * @param \Exception $previous |
| 33 | 33 | */ |
| 34 | - public function __construct(string $message, $details=null, $code=null, $previous=null) |
|
| 34 | + public function __construct(string $message, $details = null, $code = null, $previous = null) |
|
| 35 | 35 | { |
| 36 | 36 | parent::__construct($message, $code, $previous); |
| 37 | 37 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function getDetails() : string |
| 46 | 46 | { |
| 47 | - if($this->details !== null) { |
|
| 47 | + if ($this->details !== null) { |
|
| 48 | 48 | return $this->details; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function display() |
| 59 | 59 | { |
| 60 | - if(!headers_sent()) { |
|
| 60 | + if (!headers_sent()) { |
|
| 61 | 61 | header('Content-type:text/plain; charset=utf-8'); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | throw new BaseException(''); |
| 87 | 87 | } |
| 88 | - catch(BaseException $e) |
|
| 88 | + catch (BaseException $e) |
|
| 89 | 89 | { |
| 90 | 90 | echo self::createInfo($e)->toString(); |
| 91 | 91 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | throw new BaseException(''); |
| 102 | 102 | } |
| 103 | - catch(BaseException $e) |
|
| 103 | + catch (BaseException $e) |
|
| 104 | 104 | { |
| 105 | 105 | echo '<pre style="background:#fff;font-family:monospace;font-size:14px;color:#444;padding:16px;border:solid 1px #999;border-radius:4px;">'; |
| 106 | 106 | echo self::createInfo($e)->toString(); |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | $section = $this->addSection(self::SECTION_DEFAULT); |
| 37 | 37 | |
| 38 | - if(empty($iniString)) { |
|
| 38 | + if (empty($iniString)) { |
|
| 39 | 39 | return; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $eol = ConvertHelper::detectEOLCharacter($iniString); |
| 43 | - if($eol !== null) { |
|
| 43 | + if ($eol !== null) { |
|
| 44 | 44 | $this->eol = $eol->getCharacter(); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $total = count($lines); |
| 50 | 50 | |
| 51 | - for($i=0; $i < $total; $i++) |
|
| 51 | + for ($i = 0; $i < $total; $i++) |
|
| 52 | 52 | { |
| 53 | 53 | $line = new IniHelper_Line($lines[$i], $i); |
| 54 | 54 | |
| 55 | - if($line->isSection()) { |
|
| 55 | + if ($line->isSection()) { |
|
| 56 | 56 | $section = $this->addSection($line->getSectionName()); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $iniPath = FileHelper::requireFileExists($iniPath); |
| 83 | 83 | |
| 84 | 84 | $content = file_get_contents($iniPath); |
| 85 | - if($content !== false) { |
|
| 85 | + if ($content !== false) { |
|
| 86 | 86 | return self::createFromString($content); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | public function addSection(string $name) : IniHelper_Section |
| 129 | 129 | { |
| 130 | - if(!isset($this->sections[$name])) { |
|
| 130 | + if (!isset($this->sections[$name])) { |
|
| 131 | 131 | $this->sections[$name] = new IniHelper_Section($this, $name); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function getSection(string $name) : ?IniHelper_Section |
| 144 | 144 | { |
| 145 | - if(isset($this->sections[$name])) { |
|
| 145 | + if (isset($this->sections[$name])) { |
|
| 146 | 146 | return $this->sections[$name]; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | $result = array(); |
| 160 | 160 | |
| 161 | - foreach($this->sections as $section) |
|
| 161 | + foreach ($this->sections as $section) |
|
| 162 | 162 | { |
| 163 | - if($section->isDefault()) |
|
| 163 | + if ($section->isDefault()) |
|
| 164 | 164 | { |
| 165 | 165 | $result = array_merge($result, $section->toArray()); |
| 166 | 166 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | { |
| 201 | 201 | $parts = array(); |
| 202 | 202 | |
| 203 | - foreach($this->sections as $section) |
|
| 203 | + foreach ($this->sections as $section) |
|
| 204 | 204 | { |
| 205 | 205 | $parts[] = $section->toString(); |
| 206 | 206 | } |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public function sectionExists(string $name) : bool |
| 245 | 245 | { |
| 246 | - foreach($this->sections as $section) { |
|
| 247 | - if($section->getName() === $name) { |
|
| 246 | + foreach ($this->sections as $section) { |
|
| 247 | + if ($section->getName() === $name) { |
|
| 248 | 248 | return true; |
| 249 | 249 | } |
| 250 | 250 | } |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $path = $this->parsePath($path); |
| 275 | 275 | |
| 276 | - if(!$this->sectionExists($path['section'])) { |
|
| 276 | + if (!$this->sectionExists($path['section'])) { |
|
| 277 | 277 | return array(); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | { |
| 285 | 285 | $path = explode($this->pathSeparator, $path); |
| 286 | 286 | |
| 287 | - if(count($path) === 1) |
|
| 287 | + if (count($path) === 1) |
|
| 288 | 288 | { |
| 289 | 289 | return array( |
| 290 | 290 | 'section' => self::SECTION_DEFAULT, |
@@ -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 | /** |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @see JSHelper::JS_REGEX_OBJECT |
| 320 | 320 | * @see JSHelper::JS_REGEX_JSON |
| 321 | 321 | */ |
| 322 | - public static function buildRegexStatement(string $regex, string $statementType=self::JS_REGEX_OBJECT) : string |
|
| 322 | + public static function buildRegexStatement(string $regex, string $statementType = self::JS_REGEX_OBJECT) : string |
|
| 323 | 323 | { |
| 324 | 324 | $regex = trim($regex); |
| 325 | 325 | $separator = substr($regex, 0, 1); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | array_shift($parts); |
| 328 | 328 | |
| 329 | 329 | $modifiers = array_pop($parts); |
| 330 | - if($modifiers == $separator) { |
|
| 330 | + if ($modifiers == $separator) { |
|
| 331 | 331 | $modifiers = ''; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | // convert the anchors that are not supported in js regexes |
| 344 | 344 | $format = str_replace(array('\\A', '\\Z', '\\z'), array('^', '$', ''), $format); |
| 345 | 345 | |
| 346 | - if($statementType==self::JS_REGEX_JSON) |
|
| 346 | + if ($statementType == self::JS_REGEX_JSON) |
|
| 347 | 347 | { |
| 348 | 348 | return ConvertHelper::var2json(array( |
| 349 | 349 | 'format' => $format, |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | )); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if(!empty($modifiers)) { |
|
| 354 | + if (!empty($modifiers)) { |
|
| 355 | 355 | return sprintf( |
| 356 | 356 | 'new RegExp(%s, %s)', |
| 357 | 357 | ConvertHelper::var2json($format), |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | return $this->getBoolOption('cut'); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function setCuttingEnabled(bool $enabled=true) : ConvertHelper_WordWrapper |
|
| 66 | + public function setCuttingEnabled(bool $enabled = true) : ConvertHelper_WordWrapper |
|
| 67 | 67 | { |
| 68 | 68 | $this->setOption('cut', $enabled); |
| 69 | 69 | return $this; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | public function __construct() |
| 65 | 65 | { |
| 66 | - if(class_exists('\AppLocalize\Localization')) { |
|
| 66 | + if (class_exists('\AppLocalize\Localization')) { |
|
| 67 | 67 | \AppLocalize\Localization::onLocaleChanged(array($this, 'handle_localeChanged')); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | $epoch = 'past'; |
| 127 | 127 | $key = 'singular'; |
| 128 | - if($this->dateDiff > 1) { |
|
| 128 | + if ($this->dateDiff > 1) { |
|
| 129 | 129 | $key = 'plural'; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if($this->future) { |
|
| 132 | + if ($this->future) { |
|
| 133 | 133 | $epoch = 'future'; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | protected function initTexts() |
| 144 | 144 | { |
| 145 | - if(isset(self::$texts)) { |
|
| 145 | + if (isset(self::$texts)) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $day = (int)date("j", $this->dateTo); |
| 229 | 229 | $year = (int)date("Y", $this->dateFrom); |
| 230 | 230 | |
| 231 | - while(mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $this->dateTo) |
|
| 231 | + while (mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $this->dateTo) |
|
| 232 | 232 | { |
| 233 | 233 | $months_difference++; |
| 234 | 234 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | protected function resolveCalculations() : void |
| 250 | 250 | { |
| 251 | - if(!isset($this->dateFrom)) |
|
| 251 | + if (!isset($this->dateFrom)) |
|
| 252 | 252 | { |
| 253 | 253 | throw new ConvertHelper_Exception( |
| 254 | 254 | 'No date from has been specified.', |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // no date to set? Assume we want to use today. |
| 261 | - if(!isset($this->dateTo)) |
|
| 261 | + if (!isset($this->dateTo)) |
|
| 262 | 262 | { |
| 263 | 263 | $this->dateTo = time(); |
| 264 | 264 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | $difference = $this->dateTo - $this->dateFrom; |
| 339 | 339 | |
| 340 | - if($difference < 0) |
|
| 340 | + if ($difference < 0) |
|
| 341 | 341 | { |
| 342 | 342 | $difference = $difference * -1; |
| 343 | 343 | $this->future = true; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function __construct() |
| 38 | 38 | { |
| 39 | - if(class_exists('\AppLocalize\Localization')) { |
|
| 39 | + if (class_exists('\AppLocalize\Localization')) { |
|
| 40 | 40 | \AppLocalize\Localization::onLocaleChanged(array($this, 'handle_localeChanged')); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -69,17 +69,17 @@ discard block |
||
| 69 | 69 | $keep = $this->resolveTokens($interval); |
| 70 | 70 | |
| 71 | 71 | $parts = array(); |
| 72 | - foreach($keep as $token) |
|
| 72 | + foreach ($keep as $token) |
|
| 73 | 73 | { |
| 74 | 74 | $value = $interval->getToken($token); |
| 75 | - if($value === 0) { |
|
| 75 | + if ($value === 0) { |
|
| 76 | 76 | continue; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $parts[] = $this->translateToken($token, $interval); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if(count($parts) == 1) { |
|
| 82 | + if (count($parts) == 1) { |
|
| 83 | 83 | return $parts[0]; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | $value = $interval->getToken($token); |
| 102 | 102 | |
| 103 | 103 | $suffix = 'p'; |
| 104 | - if($value == 1) { $suffix = 's'; } |
|
| 104 | + if ($value == 1) { $suffix = 's'; } |
|
| 105 | 105 | $token .= $suffix; |
| 106 | 106 | |
| 107 | - if(!isset(self::$texts[$token])) |
|
| 107 | + if (!isset(self::$texts[$token])) |
|
| 108 | 108 | { |
| 109 | 109 | throw new ConvertHelper_Exception( |
| 110 | 110 | 'Missing interval translation', |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $offset = 0; |
| 136 | 136 | |
| 137 | - foreach($this->tokens as $token) |
|
| 137 | + foreach ($this->tokens as $token) |
|
| 138 | 138 | { |
| 139 | - if($interval->getToken($token) > 0) |
|
| 139 | + if ($interval->getToken($token) > 0) |
|
| 140 | 140 | { |
| 141 | 141 | return array_slice($this->tokens, $offset); |
| 142 | 142 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | protected function initTexts() : void |
| 154 | 154 | { |
| 155 | - if(isset(self::$texts)) { |
|
| 155 | + if (isset(self::$texts)) { |
|
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | const ERROR_OPENING_ZIP_FILE = 338003; |
| 32 | 32 | |
| 33 | - const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
| 33 | + const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
| 34 | 34 | |
| 35 | 35 | protected $options = array( |
| 36 | 36 | 'WriteThreshold' => 100 |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
| 82 | 82 | */ |
| 83 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
| 83 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
| 84 | 84 | { |
| 85 | 85 | $this->open(); |
| 86 | 86 | |
@@ -126,16 +126,16 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | protected function open() |
| 128 | 128 | { |
| 129 | - if($this->open) { |
|
| 129 | + if ($this->open) { |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if(!isset($this->zip)) { |
|
| 133 | + if (!isset($this->zip)) { |
|
| 134 | 134 | $this->zip = new \ZipArchive(); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $flag = null; |
| 138 | - if(!file_exists($this->file)) { |
|
| 138 | + if (!file_exists($this->file)) { |
|
| 139 | 139 | $flag = \ZipArchive::CREATE; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | $this->fileTracker++; |
| 177 | 177 | |
| 178 | - if($this->options['WriteThreshold'] < 1) { |
|
| 178 | + if ($this->options['WriteThreshold'] < 1) { |
|
| 179 | 179 | return; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | protected function close() |
| 190 | 190 | { |
| 191 | - if(!$this->open) { |
|
| 191 | + if (!$this->open) { |
|
| 192 | 192 | return; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | throw new ZIPHelper_Exception( |
| 198 | 198 | 'Could not save ZIP file to disk', |
| 199 | 199 | sprintf( |
| 200 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
| 201 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
| 200 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
| 201 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
| 202 | 202 | 'or trying to save to a directory that does not exist.', |
| 203 | 203 | $this->file |
| 204 | 204 | ), |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | $this->open(); |
| 215 | 215 | |
| 216 | - if($this->countFiles() < 1) |
|
| 216 | + if ($this->countFiles() < 1) |
|
| 217 | 217 | { |
| 218 | 218 | throw new ZIPHelper_Exception( |
| 219 | 219 | 'No files in the zip file', |
@@ -237,17 +237,17 @@ discard block |
||
| 237 | 237 | * @throws ZIPHelper_Exception |
| 238 | 238 | * @return string The file name that was sent (useful in case none was specified). |
| 239 | 239 | */ |
| 240 | - public function download(?string $fileName=null) : string |
|
| 240 | + public function download(?string $fileName = null) : string |
|
| 241 | 241 | { |
| 242 | 242 | $this->save(); |
| 243 | 243 | |
| 244 | - if(empty($fileName)) { |
|
| 244 | + if (empty($fileName)) { |
|
| 245 | 245 | $fileName = basename($this->file); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | header('Content-type: application/zip'); |
| 249 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
| 250 | - header('Content-length: ' . filesize($this->file)); |
|
| 249 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
| 250 | + header('Content-length: '.filesize($this->file)); |
|
| 251 | 251 | header('Pragma: no-cache'); |
| 252 | 252 | header('Expires: 0'); |
| 253 | 253 | readfile($this->file); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @param string|NULL $fileName Override the ZIP's file name for the download |
| 263 | 263 | * @see ZIPHelper::download() |
| 264 | 264 | */ |
| 265 | - public function downloadAndDelete(?string $fileName=null) |
|
| 265 | + public function downloadAndDelete(?string $fileName = null) |
|
| 266 | 266 | { |
| 267 | 267 | $this->download($fileName); |
| 268 | 268 | |
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
| 278 | 278 | * @return boolean |
| 279 | 279 | */ |
| 280 | - public function extractAll(?string $outputFolder=null) : bool |
|
| 280 | + public function extractAll(?string $outputFolder = null) : bool |
|
| 281 | 281 | { |
| 282 | - if(empty($outputFolder)) { |
|
| 282 | + if (empty($outputFolder)) { |
|
| 283 | 283 | $outputFolder = dirname($this->file); |
| 284 | 284 | } |
| 285 | 285 | |