@@ -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 |
@@ -34,41 +34,41 @@ discard block |
||
| 34 | 34 | return new XMLHelper($dom); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Creates a converter instance from an XML file. |
|
| 39 | - * @param string $xmlFile |
|
| 40 | - * @return \AppUtils\XMLHelper_Converter |
|
| 41 | - */ |
|
| 37 | + /** |
|
| 38 | + * Creates a converter instance from an XML file. |
|
| 39 | + * @param string $xmlFile |
|
| 40 | + * @return \AppUtils\XMLHelper_Converter |
|
| 41 | + */ |
|
| 42 | 42 | public static function convertFile(string $xmlFile) |
| 43 | 43 | { |
| 44 | 44 | return XMLHelper_Converter::fromFile($xmlFile); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Creates a converter from an XML string. |
|
| 49 | - * @param string $xmlString |
|
| 50 | - * @return \AppUtils\XMLHelper_Converter |
|
| 51 | - */ |
|
| 47 | + /** |
|
| 48 | + * Creates a converter from an XML string. |
|
| 49 | + * @param string $xmlString |
|
| 50 | + * @return \AppUtils\XMLHelper_Converter |
|
| 51 | + */ |
|
| 52 | 52 | public static function convertString(string $xmlString) |
| 53 | 53 | { |
| 54 | 54 | return XMLHelper_Converter::fromString($xmlString); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Creates a converter from a SimpleXMLElement instance. |
|
| 59 | - * @param \SimpleXMLElement $element |
|
| 60 | - * @return \AppUtils\XMLHelper_Converter |
|
| 61 | - */ |
|
| 57 | + /** |
|
| 58 | + * Creates a converter from a SimpleXMLElement instance. |
|
| 59 | + * @param \SimpleXMLElement $element |
|
| 60 | + * @return \AppUtils\XMLHelper_Converter |
|
| 61 | + */ |
|
| 62 | 62 | public static function convertElement(\SimpleXMLElement $element) |
| 63 | 63 | { |
| 64 | 64 | return XMLHelper_Converter::fromElement($element); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Creates a converter from a DOMElement instance. |
|
| 69 | - * @param \DOMElement $element |
|
| 70 | - * @return \AppUtils\XMLHelper_Converter |
|
| 71 | - */ |
|
| 67 | + /** |
|
| 68 | + * Creates a converter from a DOMElement instance. |
|
| 69 | + * @param \DOMElement $element |
|
| 70 | + * @return \AppUtils\XMLHelper_Converter |
|
| 71 | + */ |
|
| 72 | 72 | public static function convertDOMElement(\DOMElement $element) |
| 73 | 73 | { |
| 74 | 74 | return XMLHelper_Converter::fromDOMElement($element); |
@@ -436,31 +436,31 @@ discard block |
||
| 436 | 436 | return $this->dom->saveXML(); |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - /** |
|
| 440 | - * Creates a new SimpleXML helper instance: this |
|
| 441 | - * object is useful to work with loading XML strings |
|
| 442 | - * and files with easy access to any errors that |
|
| 443 | - * may occurr, since the simplexml functions can be |
|
| 444 | - * somewhat cryptic. |
|
| 445 | - * |
|
| 446 | - * @return XMLHelper_SimpleXML |
|
| 447 | - */ |
|
| 439 | + /** |
|
| 440 | + * Creates a new SimpleXML helper instance: this |
|
| 441 | + * object is useful to work with loading XML strings |
|
| 442 | + * and files with easy access to any errors that |
|
| 443 | + * may occurr, since the simplexml functions can be |
|
| 444 | + * somewhat cryptic. |
|
| 445 | + * |
|
| 446 | + * @return XMLHelper_SimpleXML |
|
| 447 | + */ |
|
| 448 | 448 | public static function createSimplexml() |
| 449 | 449 | { |
| 450 | 450 | return new XMLHelper_SimpleXML(); |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - /** |
|
| 454 | - * Converts a string to valid XML: can be a text only string |
|
| 455 | - * or an HTML string. Returns valid XML code. |
|
| 456 | - * |
|
| 457 | - * NOTE: The string may contain custom tags, which are |
|
| 458 | - * preserved. |
|
| 459 | - * |
|
| 460 | - * @param string $string |
|
| 461 | - * @throws XMLHelper_Exception |
|
| 462 | - * @return string |
|
| 463 | - */ |
|
| 453 | + /** |
|
| 454 | + * Converts a string to valid XML: can be a text only string |
|
| 455 | + * or an HTML string. Returns valid XML code. |
|
| 456 | + * |
|
| 457 | + * NOTE: The string may contain custom tags, which are |
|
| 458 | + * preserved. |
|
| 459 | + * |
|
| 460 | + * @param string $string |
|
| 461 | + * @throws XMLHelper_Exception |
|
| 462 | + * @return string |
|
| 463 | + */ |
|
| 464 | 464 | public static function string2xml(string $string) : string |
| 465 | 465 | { |
| 466 | 466 | if(stristr($string, '<body')) |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function addAttribute($parent, string $name, $value) |
| 110 | 110 | { |
| 111 | - if(!$parent instanceof \DOMNode) { |
|
| 111 | + if (!$parent instanceof \DOMNode) { |
|
| 112 | 112 | throw new XMLHelper_Exception( |
| 113 | 113 | 'The specified parent node is not a node instance.', |
| 114 | 114 | sprintf('Tried adding attribute [%s].', $name), |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | if (!empty($text)) { |
| 232 | 232 | $fragment = $this->dom->createDocumentFragment(); |
| 233 | - if(!@$fragment->appendXML($text)) { |
|
| 233 | + if (!@$fragment->appendXML($text)) { |
|
| 234 | 234 | throw new XMLHelper_Exception( |
| 235 | 235 | 'Cannot append XML fragment', |
| 236 | 236 | sprintf( |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param array $attributes |
| 273 | 273 | * @return \DOMNode |
| 274 | 274 | */ |
| 275 | - public function createRoot($name, $attributes=array()) |
|
| 275 | + public function createRoot($name, $attributes = array()) |
|
| 276 | 276 | { |
| 277 | 277 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
| 278 | 278 | $this->addAttributes($root, $attributes); |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | $string = str_replace('<', 'LT_ESCAPE', $string); |
| 294 | 294 | $string = str_replace('>', 'GT_ESCAPE', $string); |
| 295 | 295 | |
| 296 | - $string = str_replace(' ',' ', $string); |
|
| 297 | - $string = str_replace('&','&', $string); |
|
| 296 | + $string = str_replace(' ', ' ', $string); |
|
| 297 | + $string = str_replace('&', '&', $string); |
|
| 298 | 298 | |
| 299 | 299 | return $string; |
| 300 | 300 | } |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | public static function downloadXML($xml, $filename = 'download.xml') |
| 311 | 311 | { |
| 312 | - if(!headers_sent() && !self::$simulation) { |
|
| 313 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 312 | + if (!headers_sent() && !self::$simulation) { |
|
| 313 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | echo $xml; |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public static function displayXML($xml) |
| 327 | 327 | { |
| 328 | - if(!headers_sent() && !self::$simulation) { |
|
| 328 | + if (!headers_sent() && !self::$simulation) { |
|
| 329 | 329 | header('Content-Type:text/xml; charset=utf-8'); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if(self::$simulation) { |
|
| 332 | + if (self::$simulation) { |
|
| 333 | 333 | $xml = '<pre>'.htmlspecialchars($xml).'</pre>'; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -347,10 +347,10 @@ discard block |
||
| 347 | 347 | * @param string[] $customInfo Associative array with name => value pairs for custom tags to add to the output xml |
| 348 | 348 | * @see buildErrorXML() |
| 349 | 349 | */ |
| 350 | - public static function displayErrorXML($code, $message, $title, $customInfo=array()) |
|
| 350 | + public static function displayErrorXML($code, $message, $title, $customInfo = array()) |
|
| 351 | 351 | { |
| 352 | - if(!headers_sent() && !self::$simulation) { |
|
| 353 | - header('HTTP/1.1 400 Bad Request: ' . $title, true, 400); |
|
| 352 | + if (!headers_sent() && !self::$simulation) { |
|
| 353 | + header('HTTP/1.1 400 Bad Request: '.$title, true, 400); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo)); |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | protected static $simulation = false; |
| 360 | 360 | |
| 361 | - public static function setSimulation($simulate=true) |
|
| 361 | + public static function setSimulation($simulate = true) |
|
| 362 | 362 | { |
| 363 | 363 | self::$simulation = $simulate; |
| 364 | 364 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @param string $title |
| 407 | 407 | * @return string |
| 408 | 408 | */ |
| 409 | - public static function buildErrorXML($code, $message, $title, $customInfo=array()) |
|
| 409 | + public static function buildErrorXML($code, $message, $title, $customInfo = array()) |
|
| 410 | 410 | { |
| 411 | 411 | $xml = new \DOMDocument('1.0', 'UTF-8'); |
| 412 | 412 | $xml->formatOutput = true; |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | $helper->addTextTag($root, 'title', $title); |
| 421 | 421 | $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']); |
| 422 | 422 | |
| 423 | - foreach($customInfo as $name => $value) { |
|
| 423 | + foreach ($customInfo as $name => $value) { |
|
| 424 | 424 | $helper->addTextTag($root, $name, $value); |
| 425 | 425 | } |
| 426 | 426 | |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | public static function string2xml(string $string) : string |
| 467 | 467 | { |
| 468 | - if(stristr($string, '<body')) |
|
| 468 | + if (stristr($string, '<body')) |
|
| 469 | 469 | { |
| 470 | 470 | throw new XMLHelper_Exception( |
| 471 | 471 | 'Cannot convert string with existing body element', |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | // capture all elements except the body tag itself |
| 497 | 497 | $xml = ''; |
| 498 | - foreach($root->childNodes as $child) { |
|
| 498 | + foreach ($root->childNodes as $child) { |
|
| 499 | 499 | $xml .= $dom->saveXML($child); |
| 500 | 500 | } |
| 501 | 501 | |
@@ -163,8 +163,7 @@ |
||
| 163 | 163 | if($section->isDefault()) |
| 164 | 164 | { |
| 165 | 165 | $result = array_merge($result, $section->toArray()); |
| 166 | - } |
|
| 167 | - else |
|
| 166 | + } else |
|
| 168 | 167 | { |
| 169 | 168 | $result[$section->getName()] = $section->toArray(); |
| 170 | 169 | } |
@@ -60,23 +60,23 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * The end of line character used in the INI source string. |
|
| 65 | - * @return string |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * The end of line character used in the INI source string. |
|
| 65 | + * @return string |
|
| 66 | + */ |
|
| 67 | 67 | public function getEOLChar() : string |
| 68 | 68 | { |
| 69 | 69 | return $this->eol; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Factory method: creates a new helper instance loading the |
|
| 74 | - * ini content from the specified file. |
|
| 75 | - * |
|
| 76 | - * @param string $iniPath |
|
| 77 | - * @throws IniHelper_Exception |
|
| 78 | - * @return \AppUtils\IniHelper |
|
| 79 | - */ |
|
| 72 | + /** |
|
| 73 | + * Factory method: creates a new helper instance loading the |
|
| 74 | + * ini content from the specified file. |
|
| 75 | + * |
|
| 76 | + * @param string $iniPath |
|
| 77 | + * @throws IniHelper_Exception |
|
| 78 | + * @return \AppUtils\IniHelper |
|
| 79 | + */ |
|
| 80 | 80 | public static function createFromFile(string $iniPath) |
| 81 | 81 | { |
| 82 | 82 | $iniPath = FileHelper::requireFileExists($iniPath); |
@@ -96,35 +96,35 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Factory method: Creates a new ini helper instance from an ini string. |
|
| 101 | - * |
|
| 102 | - * @param string $iniContent |
|
| 103 | - * @return \AppUtils\IniHelper |
|
| 104 | - */ |
|
| 99 | + /** |
|
| 100 | + * Factory method: Creates a new ini helper instance from an ini string. |
|
| 101 | + * |
|
| 102 | + * @param string $iniContent |
|
| 103 | + * @return \AppUtils\IniHelper |
|
| 104 | + */ |
|
| 105 | 105 | public static function createFromString(string $iniContent) |
| 106 | 106 | { |
| 107 | 107 | return new IniHelper($iniContent); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Factory method: Creates a new empty ini helper. |
|
| 112 | - * |
|
| 113 | - * @return \AppUtils\IniHelper |
|
| 114 | - */ |
|
| 110 | + /** |
|
| 111 | + * Factory method: Creates a new empty ini helper. |
|
| 112 | + * |
|
| 113 | + * @return \AppUtils\IniHelper |
|
| 114 | + */ |
|
| 115 | 115 | public static function createNew() |
| 116 | 116 | { |
| 117 | 117 | return self::createFromString(''); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Adds a new data section, and returns the section instance. |
|
| 122 | - * If a section with the name already exists, returns that |
|
| 123 | - * section instead of creating a new one. |
|
| 124 | - * |
|
| 125 | - * @param string $name |
|
| 126 | - * @return IniHelper_Section |
|
| 127 | - */ |
|
| 120 | + /** |
|
| 121 | + * Adds a new data section, and returns the section instance. |
|
| 122 | + * If a section with the name already exists, returns that |
|
| 123 | + * section instead of creating a new one. |
|
| 124 | + * |
|
| 125 | + * @param string $name |
|
| 126 | + * @return IniHelper_Section |
|
| 127 | + */ |
|
| 128 | 128 | public function addSection(string $name) : IniHelper_Section |
| 129 | 129 | { |
| 130 | 130 | if(!isset($this->sections[$name])) { |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | return $this->sections[$name]; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Retrieves a section by its name, if it exists. |
|
| 139 | - * |
|
| 140 | - * @param string $name |
|
| 141 | - * @return IniHelper_Section|NULL |
|
| 142 | - */ |
|
| 137 | + /** |
|
| 138 | + * Retrieves a section by its name, if it exists. |
|
| 139 | + * |
|
| 140 | + * @param string $name |
|
| 141 | + * @return IniHelper_Section|NULL |
|
| 142 | + */ |
|
| 143 | 143 | public function getSection(string $name) : ?IniHelper_Section |
| 144 | 144 | { |
| 145 | 145 | if(isset($this->sections[$name])) { |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | return null; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Gets the data from the INI file as an associative array. |
|
| 154 | - * |
|
| 155 | - * @return array |
|
| 156 | - */ |
|
| 152 | + /** |
|
| 153 | + * Gets the data from the INI file as an associative array. |
|
| 154 | + * |
|
| 155 | + * @return array |
|
| 156 | + */ |
|
| 157 | 157 | public function toArray() : array |
| 158 | 158 | { |
| 159 | 159 | $result = array(); |
@@ -173,17 +173,17 @@ discard block |
||
| 173 | 173 | return $result; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * Saves the INI content to the target file. |
|
| 178 | - * |
|
| 179 | - * @param string $filePath |
|
| 180 | - * @return IniHelper |
|
| 181 | - * @throws FileHelper_Exception |
|
| 182 | - * |
|
| 183 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
| 184 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
| 185 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
| 186 | - */ |
|
| 176 | + /** |
|
| 177 | + * Saves the INI content to the target file. |
|
| 178 | + * |
|
| 179 | + * @param string $filePath |
|
| 180 | + * @return IniHelper |
|
| 181 | + * @throws FileHelper_Exception |
|
| 182 | + * |
|
| 183 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
| 184 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
| 185 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
| 186 | + */ |
|
| 187 | 187 | public function saveToFile(string $filePath) : IniHelper |
| 188 | 188 | { |
| 189 | 189 | FileHelper::saveFile($filePath, $this->saveToString()); |
@@ -191,11 +191,11 @@ discard block |
||
| 191 | 191 | return $this; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Returns the INI content as string. |
|
| 196 | - * |
|
| 197 | - * @return string |
|
| 198 | - */ |
|
| 194 | + /** |
|
| 195 | + * Returns the INI content as string. |
|
| 196 | + * |
|
| 197 | + * @return string |
|
| 198 | + */ |
|
| 199 | 199 | public function saveToString() : string |
| 200 | 200 | { |
| 201 | 201 | $parts = array(); |
@@ -208,15 +208,15 @@ discard block |
||
| 208 | 208 | return implode($this->eol, $parts); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - /** |
|
| 212 | - * Sets or adds the value of a setting in the INI content. |
|
| 213 | - * If the setting does not exist, it is added. Otherwise, |
|
| 214 | - * the existing value is overwritten. |
|
| 215 | - * |
|
| 216 | - * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>. |
|
| 217 | - * @param mixed $value |
|
| 218 | - * @return IniHelper |
|
| 219 | - */ |
|
| 211 | + /** |
|
| 212 | + * Sets or adds the value of a setting in the INI content. |
|
| 213 | + * If the setting does not exist, it is added. Otherwise, |
|
| 214 | + * the existing value is overwritten. |
|
| 215 | + * |
|
| 216 | + * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>. |
|
| 217 | + * @param mixed $value |
|
| 218 | + * @return IniHelper |
|
| 219 | + */ |
|
| 220 | 220 | public function setValue(string $path, $value) : IniHelper |
| 221 | 221 | { |
| 222 | 222 | $path = $this->parsePath($path); |
@@ -235,12 +235,12 @@ discard block |
||
| 235 | 235 | return $this; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Checks whether a section with the specified name exists. |
|
| 240 | - * |
|
| 241 | - * @param string $name |
|
| 242 | - * @return bool |
|
| 243 | - */ |
|
| 238 | + /** |
|
| 239 | + * Checks whether a section with the specified name exists. |
|
| 240 | + * |
|
| 241 | + * @param string $name |
|
| 242 | + * @return bool |
|
| 243 | + */ |
|
| 244 | 244 | public function sectionExists(string $name) : bool |
| 245 | 245 | { |
| 246 | 246 | foreach($this->sections as $section) { |
@@ -252,23 +252,23 @@ discard block |
||
| 252 | 252 | return false; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - /** |
|
| 256 | - * Retrieves the default section, which is used to add |
|
| 257 | - * values in the root of the document. |
|
| 258 | - * |
|
| 259 | - * @return IniHelper_Section |
|
| 260 | - */ |
|
| 255 | + /** |
|
| 256 | + * Retrieves the default section, which is used to add |
|
| 257 | + * values in the root of the document. |
|
| 258 | + * |
|
| 259 | + * @return IniHelper_Section |
|
| 260 | + */ |
|
| 261 | 261 | public function getDefaultSection() : IniHelper_Section |
| 262 | 262 | { |
| 263 | 263 | return $this->addSection(self::SECTION_DEFAULT); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * Retrieves all variable lines for the specified path. |
|
| 268 | - * |
|
| 269 | - * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>. |
|
| 270 | - * @return array|\AppUtils\IniHelper_Line[] |
|
| 271 | - */ |
|
| 266 | + /** |
|
| 267 | + * Retrieves all variable lines for the specified path. |
|
| 268 | + * |
|
| 269 | + * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>. |
|
| 270 | + * @return array|\AppUtils\IniHelper_Line[] |
|
| 271 | + */ |
|
| 272 | 272 | public function getLinesByVariable(string $path) |
| 273 | 273 | { |
| 274 | 274 | $path = $this->parsePath($path); |
@@ -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, |
@@ -26,48 +26,48 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | class JSHelper |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * Quote style using single quotes. |
|
| 31 | - * @var integer |
|
| 32 | - */ |
|
| 29 | + /** |
|
| 30 | + * Quote style using single quotes. |
|
| 31 | + * @var integer |
|
| 32 | + */ |
|
| 33 | 33 | const QUOTE_STYLE_SINGLE = 1; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Quote style using double quotes. |
|
| 37 | - * @var integer |
|
| 38 | - */ |
|
| 35 | + /** |
|
| 36 | + * Quote style using double quotes. |
|
| 37 | + * @var integer |
|
| 38 | + */ |
|
| 39 | 39 | const QUOTE_STYLE_DOUBLE = 2; |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var array |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var array |
|
| 43 | + */ |
|
| 44 | 44 | protected static $variableCache = array(); |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var integer |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * @var integer |
|
| 48 | + */ |
|
| 49 | 49 | protected static $elementCounter = 0; |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var string |
|
| 53 | - */ |
|
| 51 | + /** |
|
| 52 | + * @var string |
|
| 53 | + */ |
|
| 54 | 54 | protected static $idPrefix = 'E'; |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Builds a javascript statement. The first parameter is the |
|
| 58 | - * javascript function to call, any additional parameters are |
|
| 59 | - * used as arguments for the javascript function call. Variable |
|
| 60 | - * types are automagically converted to the javascript equivalents. |
|
| 61 | - * |
|
| 62 | - * Examples: |
|
| 63 | - * |
|
| 64 | - * // add an alert(); statement: |
|
| 65 | - * JSHelper::buildStatement('alert'); |
|
| 66 | - * |
|
| 67 | - * // add an alert('Alert text'); statement |
|
| 68 | - * JSHelper::buildStatement('alert', 'Alert text'); |
|
| 69 | - * |
|
| 70 | - */ |
|
| 56 | + /** |
|
| 57 | + * Builds a javascript statement. The first parameter is the |
|
| 58 | + * javascript function to call, any additional parameters are |
|
| 59 | + * used as arguments for the javascript function call. Variable |
|
| 60 | + * types are automagically converted to the javascript equivalents. |
|
| 61 | + * |
|
| 62 | + * Examples: |
|
| 63 | + * |
|
| 64 | + * // add an alert(); statement: |
|
| 65 | + * JSHelper::buildStatement('alert'); |
|
| 66 | + * |
|
| 67 | + * // add an alert('Alert text'); statement |
|
| 68 | + * JSHelper::buildStatement('alert', 'Alert text'); |
|
| 69 | + * |
|
| 70 | + */ |
|
| 71 | 71 | public static function buildStatement() : string |
| 72 | 72 | { |
| 73 | 73 | $args = func_get_args(); |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | return call_user_func_array(array(self::class, 'buildStatementQuoteStyle'), $args); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Like {@link JSHelper::buildStatement()}, but using single quotes |
|
| 80 | - * to make it possible to use the statement in an HTML tag attribute. |
|
| 81 | - * |
|
| 82 | - * @return string |
|
| 83 | - * @see JSHelper::buildStatement() |
|
| 84 | - */ |
|
| 78 | + /** |
|
| 79 | + * Like {@link JSHelper::buildStatement()}, but using single quotes |
|
| 80 | + * to make it possible to use the statement in an HTML tag attribute. |
|
| 81 | + * |
|
| 82 | + * @return string |
|
| 83 | + * @see JSHelper::buildStatement() |
|
| 84 | + */ |
|
| 85 | 85 | public static function buildStatementAttribute() : string |
| 86 | 86 | { |
| 87 | 87 | $args = func_get_args(); |
@@ -111,39 +111,39 @@ discard block |
||
| 111 | 111 | return $call . ');'; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Builds a set variable statement. The variable value is |
|
| 116 | - * automatically converted to the javascript equivalent. |
|
| 117 | - * |
|
| 118 | - * Examples: |
|
| 119 | - * |
|
| 120 | - * // foo = 'bar'; |
|
| 121 | - * JSHelper::buildVariable('foo', 'bar'); |
|
| 122 | - * |
|
| 123 | - * // foo = 42; |
|
| 124 | - * JSHelper::buildVariable('foo', 42); |
|
| 125 | - * |
|
| 126 | - * // foo = true; |
|
| 127 | - * JSHelper::buildVariable('foo', true); |
|
| 128 | - * |
|
| 129 | - * @param string $varName |
|
| 130 | - * @param mixed $varValue |
|
| 131 | - * @return string |
|
| 132 | - */ |
|
| 114 | + /** |
|
| 115 | + * Builds a set variable statement. The variable value is |
|
| 116 | + * automatically converted to the javascript equivalent. |
|
| 117 | + * |
|
| 118 | + * Examples: |
|
| 119 | + * |
|
| 120 | + * // foo = 'bar'; |
|
| 121 | + * JSHelper::buildVariable('foo', 'bar'); |
|
| 122 | + * |
|
| 123 | + * // foo = 42; |
|
| 124 | + * JSHelper::buildVariable('foo', 42); |
|
| 125 | + * |
|
| 126 | + * // foo = true; |
|
| 127 | + * JSHelper::buildVariable('foo', true); |
|
| 128 | + * |
|
| 129 | + * @param string $varName |
|
| 130 | + * @param mixed $varValue |
|
| 131 | + * @return string |
|
| 132 | + */ |
|
| 133 | 133 | public static function buildVariable(string $varName, $varValue) : string |
| 134 | 134 | { |
| 135 | 135 | return $varName . "=" . self::phpVariable2JS($varValue) . ';'; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * Converts a PHP variable to its javascript equivalent. Note that |
|
| 140 | - * if a variable cannot be converted (like a PHP resource), this will |
|
| 141 | - * return a javascript "null". |
|
| 142 | - * |
|
| 143 | - * @param mixed $variable |
|
| 144 | - * @param int $quoteStyle The quote style to use for strings |
|
| 145 | - * @return string |
|
| 146 | - */ |
|
| 138 | + /** |
|
| 139 | + * Converts a PHP variable to its javascript equivalent. Note that |
|
| 140 | + * if a variable cannot be converted (like a PHP resource), this will |
|
| 141 | + * return a javascript "null". |
|
| 142 | + * |
|
| 143 | + * @param mixed $variable |
|
| 144 | + * @param int $quoteStyle The quote style to use for strings |
|
| 145 | + * @return string |
|
| 146 | + */ |
|
| 147 | 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 |
@@ -221,26 +221,26 @@ discard block |
||
| 221 | 221 | return $result; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * Converts a variable to a JS string that can be |
|
| 226 | - * used in an HTML attribute: it uses single quotes |
|
| 227 | - * instead of the default double quotes. |
|
| 228 | - * |
|
| 229 | - * @param mixed $variable |
|
| 230 | - * @return string |
|
| 231 | - */ |
|
| 224 | + /** |
|
| 225 | + * Converts a variable to a JS string that can be |
|
| 226 | + * used in an HTML attribute: it uses single quotes |
|
| 227 | + * instead of the default double quotes. |
|
| 228 | + * |
|
| 229 | + * @param mixed $variable |
|
| 230 | + * @return string |
|
| 231 | + */ |
|
| 232 | 232 | public static function phpVariable2AttributeJS($variable) : string |
| 233 | 233 | { |
| 234 | 234 | return self::phpVariable2JS($variable, self::QUOTE_STYLE_SINGLE); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Generates a dynamic element ID to be used with dynamically generated |
|
| 239 | - * HTML code to tie in with clientside javascript when compact but unique |
|
| 240 | - * IDs are needed in a request. |
|
| 241 | - * |
|
| 242 | - * @return string |
|
| 243 | - */ |
|
| 237 | + /** |
|
| 238 | + * Generates a dynamic element ID to be used with dynamically generated |
|
| 239 | + * HTML code to tie in with clientside javascript when compact but unique |
|
| 240 | + * IDs are needed in a request. |
|
| 241 | + * |
|
| 242 | + * @return string |
|
| 243 | + */ |
|
| 244 | 244 | public static function nextElementID() : string |
| 245 | 245 | { |
| 246 | 246 | self::$elementCounter++; |
@@ -248,33 +248,33 @@ discard block |
||
| 248 | 248 | return self::$idPrefix . self::$elementCounter; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * Retrieves the ID prefix currently used. |
|
| 253 | - * |
|
| 254 | - * @return string |
|
| 255 | - */ |
|
| 251 | + /** |
|
| 252 | + * Retrieves the ID prefix currently used. |
|
| 253 | + * |
|
| 254 | + * @return string |
|
| 255 | + */ |
|
| 256 | 256 | public static function getIDPrefix() : string |
| 257 | 257 | { |
| 258 | 258 | return self::$idPrefix; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * Retrieves the value of the internal elements counter. |
|
| 263 | - * |
|
| 264 | - * @return integer |
|
| 265 | - */ |
|
| 261 | + /** |
|
| 262 | + * Retrieves the value of the internal elements counter. |
|
| 263 | + * |
|
| 264 | + * @return integer |
|
| 265 | + */ |
|
| 266 | 266 | public static function getElementCounter() : int |
| 267 | 267 | { |
| 268 | 268 | return self::$elementCounter; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - /** |
|
| 272 | - * Sets the prefix that is added in front of all IDs |
|
| 273 | - * retrieved using the {@link nextElementID()} method. |
|
| 274 | - * |
|
| 275 | - * @param string $prefix |
|
| 276 | - * @see JSHelper::nextElementID() |
|
| 277 | - */ |
|
| 271 | + /** |
|
| 272 | + * Sets the prefix that is added in front of all IDs |
|
| 273 | + * retrieved using the {@link nextElementID()} method. |
|
| 274 | + * |
|
| 275 | + * @param string $prefix |
|
| 276 | + * @see JSHelper::nextElementID() |
|
| 277 | + */ |
|
| 278 | 278 | public static function setIDPrefix(string $prefix) |
| 279 | 279 | { |
| 280 | 280 | self::$idPrefix = $prefix; |
@@ -159,8 +159,7 @@ discard block |
||
| 159 | 159 | if($hash === true) |
| 160 | 160 | { |
| 161 | 161 | $hash = 'true'; |
| 162 | - } |
|
| 163 | - else if($hash === false) |
|
| 162 | + } else if($hash === false) |
|
| 164 | 163 | { |
| 165 | 164 | $hash = 'false'; |
| 166 | 165 | } |
@@ -184,8 +183,7 @@ discard block |
||
| 184 | 183 | if($string === false) |
| 185 | 184 | { |
| 186 | 185 | $string = ''; |
| 187 | - } |
|
| 188 | - else if($quoteStyle === self::QUOTE_STYLE_SINGLE) |
|
| 186 | + } else if($quoteStyle === self::QUOTE_STYLE_SINGLE) |
|
| 189 | 187 | { |
| 190 | 188 | $string = mb_substr($string, 1, mb_strlen($string)-2); |
| 191 | 189 | $string = "'".str_replace("'", "\'", $string)."'"; |
@@ -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), |
@@ -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 | |
@@ -24,56 +24,56 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | class PaginationHelper |
| 26 | 26 | { |
| 27 | - /** |
|
| 28 | - * @var int |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var int |
|
| 29 | + */ |
|
| 30 | 30 | protected $total; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var int |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var int |
|
| 34 | + */ |
|
| 35 | 35 | protected $perPage; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var int |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var int |
|
| 39 | + */ |
|
| 40 | 40 | protected $current; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var int |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var int |
|
| 44 | + */ |
|
| 45 | 45 | protected $next = 0; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var int |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var int |
|
| 49 | + */ |
|
| 50 | 50 | protected $prev = 0; |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var int |
|
| 54 | - */ |
|
| 52 | + /** |
|
| 53 | + * @var int |
|
| 54 | + */ |
|
| 55 | 55 | protected $last = 0; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var int |
|
| 59 | - */ |
|
| 57 | + /** |
|
| 58 | + * @var int |
|
| 59 | + */ |
|
| 60 | 60 | protected $adjacentPages = 3; |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @var int |
|
| 64 | - */ |
|
| 62 | + /** |
|
| 63 | + * @var int |
|
| 64 | + */ |
|
| 65 | 65 | protected $offsetEnd = 0; |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @var int |
|
| 69 | - */ |
|
| 67 | + /** |
|
| 68 | + * @var int |
|
| 69 | + */ |
|
| 70 | 70 | protected $offsetStart = 0; |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @param int $totalItems The total amount of items available. |
|
| 74 | - * @param int $itemsPerPage How many items to display per page. |
|
| 75 | - * @param int $currentPage The current page number (1-based) |
|
| 76 | - */ |
|
| 72 | + /** |
|
| 73 | + * @param int $totalItems The total amount of items available. |
|
| 74 | + * @param int $itemsPerPage How many items to display per page. |
|
| 75 | + * @param int $currentPage The current page number (1-based) |
|
| 76 | + */ |
|
| 77 | 77 | public function __construct(int $totalItems, int $itemsPerPage, int $currentPage) |
| 78 | 78 | { |
| 79 | 79 | $this->total = $totalItems; |
@@ -83,34 +83,34 @@ discard block |
||
| 83 | 83 | $this->calculate(); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Sets the amount of adjacent pages to display next to the |
|
| 88 | - * current one when using the pages list. |
|
| 89 | - * |
|
| 90 | - * @param int $amount |
|
| 91 | - * @return PaginationHelper |
|
| 92 | - */ |
|
| 86 | + /** |
|
| 87 | + * Sets the amount of adjacent pages to display next to the |
|
| 88 | + * current one when using the pages list. |
|
| 89 | + * |
|
| 90 | + * @param int $amount |
|
| 91 | + * @return PaginationHelper |
|
| 92 | + */ |
|
| 93 | 93 | public function setAdjacentPages(int $amount) : PaginationHelper |
| 94 | 94 | { |
| 95 | 95 | $this->adjacentPages = $amount; |
| 96 | 96 | return $this; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Whether there is a next page after the current page. |
|
| 101 | - * @return bool |
|
| 102 | - */ |
|
| 99 | + /** |
|
| 100 | + * Whether there is a next page after the current page. |
|
| 101 | + * @return bool |
|
| 102 | + */ |
|
| 103 | 103 | public function hasNextPage() : bool |
| 104 | 104 | { |
| 105 | 105 | return $this->next > 0; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * The next page number. Returns the last page |
|
| 110 | - * number if there is no next page. |
|
| 111 | - * |
|
| 112 | - * @return int |
|
| 113 | - */ |
|
| 108 | + /** |
|
| 109 | + * The next page number. Returns the last page |
|
| 110 | + * number if there is no next page. |
|
| 111 | + * |
|
| 112 | + * @return int |
|
| 113 | + */ |
|
| 114 | 114 | public function getNextPage() : int |
| 115 | 115 | { |
| 116 | 116 | if($this->next === 0) { |
@@ -120,21 +120,21 @@ discard block |
||
| 120 | 120 | return $this->next; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Whether there is a previous page before the current page. |
|
| 125 | - * @return bool |
|
| 126 | - */ |
|
| 123 | + /** |
|
| 124 | + * Whether there is a previous page before the current page. |
|
| 125 | + * @return bool |
|
| 126 | + */ |
|
| 127 | 127 | public function hasPreviousPage() : bool |
| 128 | 128 | { |
| 129 | 129 | return $this->prev > 0; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * The previous page number. Returns the first page |
|
| 134 | - * number if there is no previous page. |
|
| 135 | - * |
|
| 136 | - * @return int |
|
| 137 | - */ |
|
| 132 | + /** |
|
| 133 | + * The previous page number. Returns the first page |
|
| 134 | + * number if there is no previous page. |
|
| 135 | + * |
|
| 136 | + * @return int |
|
| 137 | + */ |
|
| 138 | 138 | public function getPreviousPage() : int |
| 139 | 139 | { |
| 140 | 140 | if($this->prev === 0) { |
@@ -144,21 +144,21 @@ discard block |
||
| 144 | 144 | return $this->prev; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Retrieves the last page number. |
|
| 149 | - * @return int |
|
| 150 | - */ |
|
| 147 | + /** |
|
| 148 | + * Retrieves the last page number. |
|
| 149 | + * @return int |
|
| 150 | + */ |
|
| 151 | 151 | public function getLastPage() : int |
| 152 | 152 | { |
| 153 | 153 | return $this->last; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Whether there is more than one page, i.e. whether |
|
| 158 | - * pagination is required at all. |
|
| 159 | - * |
|
| 160 | - * @return bool |
|
| 161 | - */ |
|
| 156 | + /** |
|
| 157 | + * Whether there is more than one page, i.e. whether |
|
| 158 | + * pagination is required at all. |
|
| 159 | + * |
|
| 160 | + * @return bool |
|
| 161 | + */ |
|
| 162 | 162 | public function hasPages() : bool |
| 163 | 163 | { |
| 164 | 164 | return $this->last > 1; |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | return $this->current; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Retrieves a list of page numbers for a page |
|
| 174 | - * navigator, to quickly jump between pages. |
|
| 175 | - * |
|
| 176 | - * @return int[] |
|
| 177 | - */ |
|
| 172 | + /** |
|
| 173 | + * Retrieves a list of page numbers for a page |
|
| 174 | + * navigator, to quickly jump between pages. |
|
| 175 | + * |
|
| 176 | + * @return int[] |
|
| 177 | + */ |
|
| 178 | 178 | public function getPageNumbers() : array |
| 179 | 179 | { |
| 180 | 180 | $adjacent = $this->adjacentPages; |
@@ -250,66 +250,66 @@ discard block |
||
| 250 | 250 | return $numbers; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Whether the specified page number is the current page. |
|
| 255 | - * |
|
| 256 | - * @param int $pageNumber |
|
| 257 | - * @return bool |
|
| 258 | - */ |
|
| 253 | + /** |
|
| 254 | + * Whether the specified page number is the current page. |
|
| 255 | + * |
|
| 256 | + * @param int $pageNumber |
|
| 257 | + * @return bool |
|
| 258 | + */ |
|
| 259 | 259 | public function isCurrentPage(int $pageNumber) : bool |
| 260 | 260 | { |
| 261 | 261 | return $pageNumber === $this->current; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - /** |
|
| 265 | - * Retrieves the 1-based starting offset of |
|
| 266 | - * items currently displayed in the page. |
|
| 267 | - * |
|
| 268 | - * Note: Use this to create a text like |
|
| 269 | - * "showing entries x to y". |
|
| 270 | - * |
|
| 271 | - * @return int |
|
| 272 | - * @see PaginationHelper::getOffsetEnd() |
|
| 273 | - */ |
|
| 264 | + /** |
|
| 265 | + * Retrieves the 1-based starting offset of |
|
| 266 | + * items currently displayed in the page. |
|
| 267 | + * |
|
| 268 | + * Note: Use this to create a text like |
|
| 269 | + * "showing entries x to y". |
|
| 270 | + * |
|
| 271 | + * @return int |
|
| 272 | + * @see PaginationHelper::getOffsetEnd() |
|
| 273 | + */ |
|
| 274 | 274 | public function getItemsStart() : int |
| 275 | 275 | { |
| 276 | 276 | return $this->getOffsetStart() + 1; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - /** |
|
| 280 | - * Retrieves the 1-based ending offset of |
|
| 281 | - * items currently displayed in the page. |
|
| 282 | - * |
|
| 283 | - * Note: Use this to create a text like |
|
| 284 | - * "showing entries x to y". |
|
| 285 | - * |
|
| 286 | - * @return int |
|
| 287 | - * @see PaginationHelper::getOffsetStart() |
|
| 288 | - */ |
|
| 279 | + /** |
|
| 280 | + * Retrieves the 1-based ending offset of |
|
| 281 | + * items currently displayed in the page. |
|
| 282 | + * |
|
| 283 | + * Note: Use this to create a text like |
|
| 284 | + * "showing entries x to y". |
|
| 285 | + * |
|
| 286 | + * @return int |
|
| 287 | + * @see PaginationHelper::getOffsetStart() |
|
| 288 | + */ |
|
| 289 | 289 | public function getItemsEnd() : int |
| 290 | 290 | { |
| 291 | 291 | return $this->getOffsetEnd() + 1; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - /** |
|
| 295 | - * Retrieves the 0-based starting offset of |
|
| 296 | - * items currently displayed in the page. |
|
| 297 | - * |
|
| 298 | - * @return int |
|
| 299 | - * @see PaginationHelper::getItemsStart() |
|
| 300 | - */ |
|
| 294 | + /** |
|
| 295 | + * Retrieves the 0-based starting offset of |
|
| 296 | + * items currently displayed in the page. |
|
| 297 | + * |
|
| 298 | + * @return int |
|
| 299 | + * @see PaginationHelper::getItemsStart() |
|
| 300 | + */ |
|
| 301 | 301 | public function getOffsetStart() : int |
| 302 | 302 | { |
| 303 | 303 | return $this->offsetStart; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - /** |
|
| 307 | - * Retrieves the 0-based ending offset of |
|
| 308 | - * items currently displayed in the page. |
|
| 309 | - * |
|
| 310 | - * @return int |
|
| 311 | - * @see PaginationHelper::getItemsEnd() |
|
| 312 | - */ |
|
| 306 | + /** |
|
| 307 | + * Retrieves the 0-based ending offset of |
|
| 308 | + * items currently displayed in the page. |
|
| 309 | + * |
|
| 310 | + * @return int |
|
| 311 | + * @see PaginationHelper::getItemsEnd() |
|
| 312 | + */ |
|
| 313 | 313 | public function getOffsetEnd() : int |
| 314 | 314 | { |
| 315 | 315 | return $this->offsetEnd; |
@@ -322,8 +322,7 @@ |
||
| 322 | 322 | if($this->current < 1) |
| 323 | 323 | { |
| 324 | 324 | $this->current = 1; |
| 325 | - } |
|
| 326 | - else if($this->current > $pages) |
|
| 325 | + } else if($this->current > $pages) |
|
| 327 | 326 | { |
| 328 | 327 | $this->current = $pages; |
| 329 | 328 | } |
@@ -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 | } |
@@ -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 | } |
@@ -23,101 +23,101 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class SVNHelper |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @var integer |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var integer |
|
| 28 | + */ |
|
| 29 | 29 | const ERROR_LOCAL_PATH_DOES_NOT_EXIST = 22401; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var integer |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var integer |
|
| 33 | + */ |
|
| 34 | 34 | const ERROR_INVALID_REP_URL = 22402; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var integer |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var integer |
|
| 38 | + */ |
|
| 39 | 39 | const ERROR_PATH_IS_OUTSIDE_REPOSITORY = 22403; |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var integer |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var integer |
|
| 43 | + */ |
|
| 44 | 44 | const ERROR_TARGET_FOLDER_IS_A_FILE = 22404; |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var integer |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * @var integer |
|
| 48 | + */ |
|
| 49 | 49 | const ERROR_CANNOT_ADD_INEXISTENT_FILE = 22405; |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var integer |
|
| 53 | - */ |
|
| 51 | + /** |
|
| 52 | + * @var integer |
|
| 53 | + */ |
|
| 54 | 54 | const ERROR_TARGET_PATH_NOT_FOUND = 22406; |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var integer |
|
| 58 | - */ |
|
| 56 | + /** |
|
| 57 | + * @var integer |
|
| 58 | + */ |
|
| 59 | 59 | const ERROR_INVALID_TARGET_TYPE = 22407; |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @var integer |
|
| 63 | - */ |
|
| 61 | + /** |
|
| 62 | + * @var integer |
|
| 63 | + */ |
|
| 64 | 64 | const ERROR_INVALID_LOG_CALLBACK = 22408; |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @var SVNHelper_Target_Folder |
|
| 68 | - */ |
|
| 66 | + /** |
|
| 67 | + * @var SVNHelper_Target_Folder |
|
| 68 | + */ |
|
| 69 | 69 | protected $target; |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @var string |
|
| 73 | - */ |
|
| 71 | + /** |
|
| 72 | + * @var string |
|
| 73 | + */ |
|
| 74 | 74 | protected $path; |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @var string |
|
| 78 | - */ |
|
| 76 | + /** |
|
| 77 | + * @var string |
|
| 78 | + */ |
|
| 79 | 79 | protected $url; |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @var string |
|
| 83 | - */ |
|
| 81 | + /** |
|
| 82 | + * @var string |
|
| 83 | + */ |
|
| 84 | 84 | protected $user; |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @var string |
|
| 88 | - */ |
|
| 86 | + /** |
|
| 87 | + * @var string |
|
| 88 | + */ |
|
| 89 | 89 | protected $pass; |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @var array |
|
| 93 | - */ |
|
| 91 | + /** |
|
| 92 | + * @var array |
|
| 93 | + */ |
|
| 94 | 94 | protected $options = array( |
| 95 | 95 | 'binaries-path' => '' |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * @var boolean |
|
| 100 | - */ |
|
| 98 | + /** |
|
| 99 | + * @var boolean |
|
| 100 | + */ |
|
| 101 | 101 | protected $isWindows = false; |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @var array |
|
| 105 | - */ |
|
| 103 | + /** |
|
| 104 | + * @var array |
|
| 105 | + */ |
|
| 106 | 106 | protected $normalize = array( |
| 107 | 107 | 'from' => '\\', |
| 108 | 108 | 'to' => '/' |
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * @var string |
|
| 113 | - */ |
|
| 111 | + /** |
|
| 112 | + * @var string |
|
| 113 | + */ |
|
| 114 | 114 | protected $sourcePath; |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * @param string $repPath The path to the repository |
|
| 118 | - * @param string $repURL The SVN URL to the repository |
|
| 119 | - * @throws SVNHelper_Exception |
|
| 120 | - */ |
|
| 116 | + /** |
|
| 117 | + * @param string $repPath The path to the repository |
|
| 118 | + * @param string $repURL The SVN URL to the repository |
|
| 119 | + * @throws SVNHelper_Exception |
|
| 120 | + */ |
|
| 121 | 121 | public function __construct(string $repPath, string $repURL) |
| 122 | 122 | { |
| 123 | 123 | $this->isWindows = substr(PHP_OS, 0, 3) == 'WIN'; |
@@ -178,16 +178,16 @@ discard block |
||
| 178 | 178 | return $this->pass; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * Normalizes slashes in the path according to the |
|
| 183 | - * operating system, i.e. forward slashes for NIX-systems |
|
| 184 | - * and backward slashes for Windows. |
|
| 185 | - * |
|
| 186 | - * @param string $path An absolute path to normalize |
|
| 187 | - * @param bool $relativize Whether to return a path relative to the repository |
|
| 188 | - * @throws SVNHelper_Exception |
|
| 189 | - * @return string |
|
| 190 | - */ |
|
| 181 | + /** |
|
| 182 | + * Normalizes slashes in the path according to the |
|
| 183 | + * operating system, i.e. forward slashes for NIX-systems |
|
| 184 | + * and backward slashes for Windows. |
|
| 185 | + * |
|
| 186 | + * @param string $path An absolute path to normalize |
|
| 187 | + * @param bool $relativize Whether to return a path relative to the repository |
|
| 188 | + * @throws SVNHelper_Exception |
|
| 189 | + * @return string |
|
| 190 | + */ |
|
| 191 | 191 | public function normalizePath($path, $relativize=false) |
| 192 | 192 | { |
| 193 | 193 | if(empty($path)) { |
@@ -222,32 +222,32 @@ discard block |
||
| 222 | 222 | ); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - /** |
|
| 226 | - * Retrieves the path slash style according to the |
|
| 227 | - * current operating system. |
|
| 228 | - * |
|
| 229 | - * @return string |
|
| 230 | - */ |
|
| 225 | + /** |
|
| 226 | + * Retrieves the path slash style according to the |
|
| 227 | + * current operating system. |
|
| 228 | + * |
|
| 229 | + * @return string |
|
| 230 | + */ |
|
| 231 | 231 | public function getSlash() |
| 232 | 232 | { |
| 233 | 233 | return $this->normalize['to']; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Keeps instances of files. |
|
| 238 | - * @var SVNHelper_Target[] |
|
| 239 | - */ |
|
| 236 | + /** |
|
| 237 | + * Keeps instances of files. |
|
| 238 | + * @var SVNHelper_Target[] |
|
| 239 | + */ |
|
| 240 | 240 | protected $targets = array(); |
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * Retrieves a file instance from the SVN repository: |
|
| 244 | - * this allows all possible operations on the file as |
|
| 245 | - * well as accessing more information on it. |
|
| 246 | - * |
|
| 247 | - * @param string $path A path to the file, relative to the repository path or absolute. |
|
| 248 | - * @return SVNHelper_Target_File |
|
| 249 | - * @throws SVNHelper_Exception |
|
| 250 | - */ |
|
| 242 | + /** |
|
| 243 | + * Retrieves a file instance from the SVN repository: |
|
| 244 | + * this allows all possible operations on the file as |
|
| 245 | + * well as accessing more information on it. |
|
| 246 | + * |
|
| 247 | + * @param string $path A path to the file, relative to the repository path or absolute. |
|
| 248 | + * @return SVNHelper_Target_File |
|
| 249 | + * @throws SVNHelper_Exception |
|
| 250 | + */ |
|
| 251 | 251 | public function getFile($path) |
| 252 | 252 | { |
| 253 | 253 | $path = $this->filterPath($path); |
@@ -255,15 +255,15 @@ discard block |
||
| 255 | 255 | return $this->getTarget('File', $this->relativizePath($path)); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - /** |
|
| 259 | - * Retrieves a folder instance from the SVN repository: |
|
| 260 | - * This allows all possible operations on the folder as |
|
| 261 | - * well as accessing more information on it. |
|
| 262 | - * |
|
| 263 | - * @param string $path |
|
| 264 | - * @return SVNHelper_Target_Folder |
|
| 265 | - * @throws SVNHelper_Exception |
|
| 266 | - */ |
|
| 258 | + /** |
|
| 259 | + * Retrieves a folder instance from the SVN repository: |
|
| 260 | + * This allows all possible operations on the folder as |
|
| 261 | + * well as accessing more information on it. |
|
| 262 | + * |
|
| 263 | + * @param string $path |
|
| 264 | + * @return SVNHelper_Target_Folder |
|
| 265 | + * @throws SVNHelper_Exception |
|
| 266 | + */ |
|
| 267 | 267 | public function getFolder($path) |
| 268 | 268 | { |
| 269 | 269 | $path = $this->filterPath($path); |
@@ -271,13 +271,13 @@ discard block |
||
| 271 | 271 | return $this->getTarget('Folder', $this->relativizePath($path)); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * Passes the path through realpath and ensures it exists. |
|
| 276 | - * |
|
| 277 | - * @param string $path |
|
| 278 | - * @throws SVNHelper_Exception |
|
| 279 | - * @return string |
|
| 280 | - */ |
|
| 274 | + /** |
|
| 275 | + * Passes the path through realpath and ensures it exists. |
|
| 276 | + * |
|
| 277 | + * @param string $path |
|
| 278 | + * @throws SVNHelper_Exception |
|
| 279 | + * @return string |
|
| 280 | + */ |
|
| 281 | 281 | protected function filterPath($path) |
| 282 | 282 | { |
| 283 | 283 | if(empty($path)) { |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | ); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - /** |
|
| 306 | - * Retrieves a target file or folder within the repository. |
|
| 307 | - * |
|
| 308 | - * @param string $type The target type, "File" or "Folder". |
|
| 309 | - * @param string $relativePath A path relative to the root folder. |
|
| 310 | - * @return SVNHelper_Target |
|
| 311 | - */ |
|
| 305 | + /** |
|
| 306 | + * Retrieves a target file or folder within the repository. |
|
| 307 | + * |
|
| 308 | + * @param string $type The target type, "File" or "Folder". |
|
| 309 | + * @param string $relativePath A path relative to the root folder. |
|
| 310 | + * @return SVNHelper_Target |
|
| 311 | + */ |
|
| 312 | 312 | protected function getTarget($type, $relativePath) |
| 313 | 313 | { |
| 314 | 314 | $key = $type.':'.$relativePath; |
@@ -356,33 +356,33 @@ discard block |
||
| 356 | 356 | return $this->url; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - /** |
|
| 360 | - * Updates the whole SVN repository from the root folder. |
|
| 361 | - * @return SVNHelper_CommandResult |
|
| 362 | - */ |
|
| 359 | + /** |
|
| 360 | + * Updates the whole SVN repository from the root folder. |
|
| 361 | + * @return SVNHelper_CommandResult |
|
| 362 | + */ |
|
| 363 | 363 | public function runUpdate() |
| 364 | 364 | { |
| 365 | 365 | return $this->createUpdate($this->target)->execute(); |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - /** |
|
| 369 | - * Creates an update command for the target file or folder. |
|
| 370 | - * This can be configured further before it is executed. |
|
| 371 | - * |
|
| 372 | - * @param SVNHelper_Target $target |
|
| 373 | - * @return SVNHelper_Command_Update |
|
| 374 | - */ |
|
| 368 | + /** |
|
| 369 | + * Creates an update command for the target file or folder. |
|
| 370 | + * This can be configured further before it is executed. |
|
| 371 | + * |
|
| 372 | + * @param SVNHelper_Target $target |
|
| 373 | + * @return SVNHelper_Command_Update |
|
| 374 | + */ |
|
| 375 | 375 | public function createUpdate(SVNHelper_Target $target) |
| 376 | 376 | { |
| 377 | 377 | return $this->createCommand('Update', $target); |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - /** |
|
| 381 | - * Creates an add command for the targt file or folder. |
|
| 382 | - * |
|
| 383 | - * @param SVNHelper_Target $target |
|
| 384 | - * @return SVNHelper_Command_Add |
|
| 385 | - */ |
|
| 380 | + /** |
|
| 381 | + * Creates an add command for the targt file or folder. |
|
| 382 | + * |
|
| 383 | + * @param SVNHelper_Target $target |
|
| 384 | + * @return SVNHelper_Command_Add |
|
| 385 | + */ |
|
| 386 | 386 | public function createAdd(SVNHelper_Target $target) |
| 387 | 387 | { |
| 388 | 388 | return $this->createCommand('Add', $target); |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | return $this->createCommand('Info', $target); |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - /** |
|
| 403 | - * Creates a status command for the target file or folder. |
|
| 404 | - * |
|
| 405 | - * @param SVNHelper_Target $target |
|
| 406 | - * @return SVNHelper_Command_Status |
|
| 407 | - */ |
|
| 402 | + /** |
|
| 403 | + * Creates a status command for the target file or folder. |
|
| 404 | + * |
|
| 405 | + * @param SVNHelper_Target $target |
|
| 406 | + * @return SVNHelper_Command_Status |
|
| 407 | + */ |
|
| 408 | 408 | public function createStatus(SVNHelper_Target $target) |
| 409 | 409 | { |
| 410 | 410 | return $this->createCommand('Status', $target); |
@@ -429,28 +429,28 @@ discard block |
||
| 429 | 429 | return $cmd; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - /** |
|
| 433 | - * Creates a path relative to the repository for the target |
|
| 434 | - * file or folder, from an absolute path. |
|
| 435 | - * |
|
| 436 | - * @param string $path An absolute path. |
|
| 437 | - * @return string |
|
| 438 | - */ |
|
| 432 | + /** |
|
| 433 | + * Creates a path relative to the repository for the target |
|
| 434 | + * file or folder, from an absolute path. |
|
| 435 | + * |
|
| 436 | + * @param string $path An absolute path. |
|
| 437 | + * @return string |
|
| 438 | + */ |
|
| 439 | 439 | public function relativizePath($path) |
| 440 | 440 | { |
| 441 | 441 | return $this->normalizePath($path, true); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - /** |
|
| 445 | - * Adds a folder: creates it as necessary (recursive), |
|
| 446 | - * and adds it to be committed if it is not versioned yet. |
|
| 447 | - * Use this instead of {@link getFolder()} when you are |
|
| 448 | - * not sure that it exists yet, and will need it. |
|
| 449 | - * |
|
| 450 | - * @param string $path Absolute or relative path to the folder |
|
| 451 | - * @throws SVNHelper_Exception |
|
| 452 | - * @return SVNHelper_Target_Folder |
|
| 453 | - */ |
|
| 444 | + /** |
|
| 445 | + * Adds a folder: creates it as necessary (recursive), |
|
| 446 | + * and adds it to be committed if it is not versioned yet. |
|
| 447 | + * Use this instead of {@link getFolder()} when you are |
|
| 448 | + * not sure that it exists yet, and will need it. |
|
| 449 | + * |
|
| 450 | + * @param string $path Absolute or relative path to the folder |
|
| 451 | + * @throws SVNHelper_Exception |
|
| 452 | + * @return SVNHelper_Target_Folder |
|
| 453 | + */ |
|
| 454 | 454 | public function addFolder($path) |
| 455 | 455 | { |
| 456 | 456 | if(is_dir($path)) { |
@@ -500,14 +500,14 @@ discard block |
||
| 500 | 500 | |
| 501 | 501 | protected static $logCallback; |
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * Sets the callback function/method to use for |
|
| 505 | - * SVH helper log messages. This gets the message |
|
| 506 | - * and the SVNHelper instance as parameters. |
|
| 507 | - * |
|
| 508 | - * @param callable $callback |
|
| 509 | - * @throws SVNHelper_Exception |
|
| 510 | - */ |
|
| 503 | + /** |
|
| 504 | + * Sets the callback function/method to use for |
|
| 505 | + * SVH helper log messages. This gets the message |
|
| 506 | + * and the SVNHelper instance as parameters. |
|
| 507 | + * |
|
| 508 | + * @param callable $callback |
|
| 509 | + * @throws SVNHelper_Exception |
|
| 510 | + */ |
|
| 511 | 511 | public static function setLogCallback($callback) |
| 512 | 512 | { |
| 513 | 513 | if(!is_callable($callback)) { |
@@ -528,22 +528,22 @@ discard block |
||
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - /** |
|
| 532 | - * Retrieves information about the file, and adds it |
|
| 533 | - * to be committed later if it not versioned yet. |
|
| 534 | - * |
|
| 535 | - * @param string $path |
|
| 536 | - * @return SVNHelper_Target_File |
|
| 537 | - */ |
|
| 531 | + /** |
|
| 532 | + * Retrieves information about the file, and adds it |
|
| 533 | + * to be committed later if it not versioned yet. |
|
| 534 | + * |
|
| 535 | + * @param string $path |
|
| 536 | + * @return SVNHelper_Target_File |
|
| 537 | + */ |
|
| 538 | 538 | public function addFile($path) |
| 539 | 539 | { |
| 540 | 540 | return $this->getFile($path)->runAdd(); |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - /** |
|
| 544 | - * Commits all changes in the repository. |
|
| 545 | - * @param string $message The commit message to log. |
|
| 546 | - */ |
|
| 543 | + /** |
|
| 544 | + * Commits all changes in the repository. |
|
| 545 | + * @param string $message The commit message to log. |
|
| 546 | + */ |
|
| 547 | 547 | public function runCommit($message) |
| 548 | 548 | { |
| 549 | 549 | $this->createCommit($this->getFolder($this->path), $message)->execute(); |
@@ -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 | } |