@@ -59,8 +59,7 @@ discard block |
||
59 | 59 | try |
60 | 60 | { |
61 | 61 | throw new BaseException(''); |
62 | - } |
|
63 | - catch(BaseException $e) |
|
62 | + } catch(BaseException $e) |
|
64 | 63 | { |
65 | 64 | echo self::createInfo($e)->toString(); |
66 | 65 | } |
@@ -74,8 +73,7 @@ discard block |
||
74 | 73 | try |
75 | 74 | { |
76 | 75 | throw new BaseException(''); |
77 | - } |
|
78 | - catch(BaseException $e) |
|
76 | + } catch(BaseException $e) |
|
79 | 77 | { |
80 | 78 | echo '<pre style="background:#fff;font-family:monospace;font-size:14px;color:#444;padding:16px;border:solid 1px #999;border-radius:4px;">'; |
81 | 79 | echo self::createInfo($e)->toString(); |
@@ -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(); |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class BaseException extends \Exception |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | 26 | protected $details; |
27 | 27 | |
28 | - /** |
|
29 | - * @param string $message |
|
30 | - * @param string $details |
|
31 | - * @param int $code |
|
32 | - * @param \Exception $previous |
|
33 | - */ |
|
28 | + /** |
|
29 | + * @param string $message |
|
30 | + * @param string $details |
|
31 | + * @param int $code |
|
32 | + * @param \Exception $previous |
|
33 | + */ |
|
34 | 34 | public function __construct(string $message, $details=null, $code=null, $previous=null) |
35 | 35 | { |
36 | 36 | parent::__construct($message, $code, $previous); |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | $this->details = $details; |
39 | 39 | } |
40 | 40 | |
41 | - /** |
|
42 | - * Retrieves the detailed error description, if any. |
|
43 | - * @return string |
|
44 | - */ |
|
41 | + /** |
|
42 | + * Retrieves the detailed error description, if any. |
|
43 | + * @return string |
|
44 | + */ |
|
45 | 45 | public function getDetails() : string |
46 | 46 | { |
47 | 47 | if($this->details !== null) { |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | return ''; |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * Displays pertinent information on the exception. |
|
56 | - */ |
|
54 | + /** |
|
55 | + * Displays pertinent information on the exception. |
|
56 | + */ |
|
57 | 57 | public function display() |
58 | 58 | { |
59 | 59 | if(!headers_sent()) { |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | echo $this->getInfo(); |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Retrieves information on the exception that can be |
|
68 | - * easily accessed. |
|
69 | - * |
|
70 | - * @return ConvertHelper_ThrowableInfo |
|
71 | - */ |
|
66 | + /** |
|
67 | + * Retrieves information on the exception that can be |
|
68 | + * easily accessed. |
|
69 | + * |
|
70 | + * @return ConvertHelper_ThrowableInfo |
|
71 | + */ |
|
72 | 72 | public function getInfo() : ConvertHelper_ThrowableInfo |
73 | 73 | { |
74 | 74 | return ConvertHelper::throwable2info($this); |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * Dumps a current PHP function trace, as a textonly string. |
|
79 | - */ |
|
77 | + /** |
|
78 | + * Dumps a current PHP function trace, as a textonly string. |
|
79 | + */ |
|
80 | 80 | public static function dumpTraceAsString() |
81 | 81 | { |
82 | 82 | try |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * Dumps a current PHP function trace, with HTML styling. |
|
94 | - */ |
|
92 | + /** |
|
93 | + * Dumps a current PHP function trace, with HTML styling. |
|
94 | + */ |
|
95 | 95 | public static function dumpTraceAsHTML() |
96 | 96 | { |
97 | 97 | try |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Creates an exception info instance from a throwable instance. |
|
111 | - * |
|
112 | - * @param \Throwable $e |
|
113 | - * @return ConvertHelper_ThrowableInfo |
|
114 | - * @see ConvertHelper::throwable2info() |
|
115 | - */ |
|
109 | + /** |
|
110 | + * Creates an exception info instance from a throwable instance. |
|
111 | + * |
|
112 | + * @param \Throwable $e |
|
113 | + * @return ConvertHelper_ThrowableInfo |
|
114 | + * @see ConvertHelper::throwable2info() |
|
115 | + */ |
|
116 | 116 | public static function createInfo(\Throwable $e) : ConvertHelper_ThrowableInfo |
117 | 117 | { |
118 | 118 | return ConvertHelper::throwable2info($e); |
@@ -38,38 +38,38 @@ |
||
38 | 38 | */ |
39 | 39 | protected $text; |
40 | 40 | |
41 | - /** |
|
42 | - * @var string |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var string |
|
43 | + */ |
|
44 | 44 | protected $trimmed; |
45 | 45 | |
46 | - /** |
|
47 | - * @var int |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var int |
|
48 | + */ |
|
49 | 49 | protected $lineNumber; |
50 | 50 | |
51 | - /** |
|
52 | - * @var string |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var string |
|
53 | + */ |
|
54 | 54 | protected $type; |
55 | 55 | |
56 | - /** |
|
57 | - * @var string |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var string |
|
58 | + */ |
|
59 | 59 | protected $varName = ''; |
60 | 60 | |
61 | - /** |
|
62 | - * @var string |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var string |
|
63 | + */ |
|
64 | 64 | protected $varValue = ''; |
65 | 65 | |
66 | 66 | protected $valueUnquoted = ''; |
67 | 67 | |
68 | 68 | protected $quoteStyle = ''; |
69 | 69 | |
70 | - /** |
|
71 | - * @var string |
|
72 | - */ |
|
70 | + /** |
|
71 | + * @var string |
|
72 | + */ |
|
73 | 73 | protected $sectionName = ''; |
74 | 74 | |
75 | 75 | public function __construct(string $text, int $lineNumber) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $this->trimmed = trim($text); |
79 | 79 | $this->lineNumber = $lineNumber; |
80 | 80 | |
81 | - if(empty($this->trimmed)) |
|
81 | + if (empty($this->trimmed)) |
|
82 | 82 | { |
83 | 83 | $this->type = self::TYPE_EMPTY; |
84 | 84 | return; |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | |
87 | 87 | $startChar = substr($this->trimmed, 0, 1); |
88 | 88 | |
89 | - if($startChar === ';') |
|
89 | + if ($startChar === ';') |
|
90 | 90 | { |
91 | 91 | $this->type = self::TYPE_COMMENT; |
92 | 92 | } |
93 | - else if($startChar === '[') |
|
93 | + else if ($startChar === '[') |
|
94 | 94 | { |
95 | 95 | $this->type = self::TYPE_SECTION_DECLARATION; |
96 | 96 | $this->sectionName = trim($this->trimmed, '[]'); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | else |
100 | 100 | { |
101 | 101 | $pos = strpos($this->trimmed, '='); |
102 | - if($pos === false) |
|
102 | + if ($pos === false) |
|
103 | 103 | { |
104 | 104 | $this->type = self::TYPE_INVALID; |
105 | 105 | return; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $this->type = self::TYPE_VALUE; |
109 | 109 | $this->varName = trim(substr($this->trimmed, 0, $pos)); |
110 | 110 | |
111 | - $this->parseValue(substr($this->trimmed, $pos+1)); |
|
111 | + $this->parseValue(substr($this->trimmed, $pos + 1)); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | |
119 | 119 | $value = $this->varValue; |
120 | 120 | |
121 | - if(substr($value, 0, 1) == '"' && substr($value, -1, 1) == '"') |
|
121 | + if (substr($value, 0, 1) == '"' && substr($value, -1, 1) == '"') |
|
122 | 122 | { |
123 | 123 | $value = trim($value, '"'); |
124 | 124 | $this->quoteStyle = '"'; |
125 | 125 | } |
126 | - else if(substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'") |
|
126 | + else if (substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'") |
|
127 | 127 | { |
128 | 128 | $value = trim($value, "'"); |
129 | 129 | $this->quoteStyle = "'"; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | public function getQuotedVarValue() : string |
146 | 146 | { |
147 | - if($this->quoteStyle === '') { |
|
147 | + if ($this->quoteStyle === '') { |
|
148 | 148 | return $this->getVarValue(); |
149 | 149 | } |
150 | 150 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | public function setValue($value) : IniHelper_Line |
200 | 200 | { |
201 | - if(!is_scalar($value)) |
|
201 | + if (!is_scalar($value)) |
|
202 | 202 | { |
203 | 203 | throw new IniHelper_Exception( |
204 | 204 | 'Cannot use non-scalar values.', |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | public function toString() : string |
220 | 220 | { |
221 | - switch($this->type) |
|
221 | + switch ($this->type) |
|
222 | 222 | { |
223 | 223 | case self::TYPE_EMPTY: |
224 | 224 | case self::TYPE_INVALID: |
@@ -89,14 +89,12 @@ discard block |
||
89 | 89 | if($startChar === ';') |
90 | 90 | { |
91 | 91 | $this->type = self::TYPE_COMMENT; |
92 | - } |
|
93 | - else if($startChar === '[') |
|
92 | + } else if($startChar === '[') |
|
94 | 93 | { |
95 | 94 | $this->type = self::TYPE_SECTION_DECLARATION; |
96 | 95 | $this->sectionName = trim($this->trimmed, '[]'); |
97 | 96 | $this->sectionName = trim($this->sectionName); // remove any whitespace |
98 | - } |
|
99 | - else |
|
97 | + } else |
|
100 | 98 | { |
101 | 99 | $pos = strpos($this->trimmed, '='); |
102 | 100 | if($pos === false) |
@@ -122,8 +120,7 @@ discard block |
||
122 | 120 | { |
123 | 121 | $value = trim($value, '"'); |
124 | 122 | $this->quoteStyle = '"'; |
125 | - } |
|
126 | - else if(substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'") |
|
123 | + } else if(substr($value, 0, 1) == "'" && substr($value, -1, 1) == "'") |
|
127 | 124 | { |
128 | 125 | $value = trim($value, "'"); |
129 | 126 | $this->quoteStyle = "'"; |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class IniHelper_Section |
23 | 23 | { |
24 | - /** |
|
25 | - * @var IniHelper |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var IniHelper |
|
26 | + */ |
|
27 | 27 | protected $ini; |
28 | 28 | |
29 | - /** |
|
30 | - * @var string |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + */ |
|
32 | 32 | protected $name; |
33 | 33 | |
34 | - /** |
|
35 | - * @var IniHelper_Line[] |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var IniHelper_Line[] |
|
36 | + */ |
|
37 | 37 | protected $lines = array(); |
38 | 38 | |
39 | 39 | public function __construct(IniHelper $ini, string $name) |
@@ -42,33 +42,33 @@ discard block |
||
42 | 42 | $this->name = $name; |
43 | 43 | } |
44 | 44 | |
45 | - /** |
|
46 | - * The section's name. |
|
47 | - * @return string |
|
48 | - */ |
|
45 | + /** |
|
46 | + * The section's name. |
|
47 | + * @return string |
|
48 | + */ |
|
49 | 49 | public function getName() : string |
50 | 50 | { |
51 | 51 | return $this->name; |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * Whether this is the default section: this |
|
56 | - * is used internally to store all variables that |
|
57 | - * are not in any specific section. |
|
58 | - * |
|
59 | - * @return bool |
|
60 | - */ |
|
54 | + /** |
|
55 | + * Whether this is the default section: this |
|
56 | + * is used internally to store all variables that |
|
57 | + * are not in any specific section. |
|
58 | + * |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | 61 | public function isDefault() : bool |
62 | 62 | { |
63 | 63 | return $this->name === IniHelper::SECTION_DEFAULT; |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Adds a line instance to the section. |
|
68 | - * |
|
69 | - * @param IniHelper_Line $line |
|
70 | - * @return IniHelper_Section |
|
71 | - */ |
|
66 | + /** |
|
67 | + * Adds a line instance to the section. |
|
68 | + * |
|
69 | + * @param IniHelper_Line $line |
|
70 | + * @return IniHelper_Section |
|
71 | + */ |
|
72 | 72 | public function addLine(IniHelper_Line $line) : IniHelper_Section |
73 | 73 | { |
74 | 74 | $this->lines[] = $line; |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | return $this; |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * Converts the values contained in the section into |
|
81 | - * an associative array. |
|
82 | - * |
|
83 | - * @return array |
|
84 | - */ |
|
79 | + /** |
|
80 | + * Converts the values contained in the section into |
|
81 | + * an associative array. |
|
82 | + * |
|
83 | + * @return array |
|
84 | + */ |
|
85 | 85 | public function toArray() : array |
86 | 86 | { |
87 | 87 | $result = array(); |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | return $result; |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Converts the section's lines into an INI string. |
|
119 | - * |
|
120 | - * @return string |
|
121 | - */ |
|
117 | + /** |
|
118 | + * Converts the section's lines into an INI string. |
|
119 | + * |
|
120 | + * @return string |
|
121 | + */ |
|
122 | 122 | public function toString() |
123 | 123 | { |
124 | 124 | $lines = array(); |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | return implode($this->ini->getEOLChar(), $lines); |
141 | 141 | } |
142 | 142 | |
143 | - /** |
|
144 | - * Deletes a line from the section. |
|
145 | - * |
|
146 | - * @param IniHelper_Line $toDelete |
|
147 | - * @return IniHelper_Section |
|
148 | - */ |
|
143 | + /** |
|
144 | + * Deletes a line from the section. |
|
145 | + * |
|
146 | + * @param IniHelper_Line $toDelete |
|
147 | + * @return IniHelper_Section |
|
148 | + */ |
|
149 | 149 | public function deleteLine(IniHelper_Line $toDelete) : IniHelper_Section |
150 | 150 | { |
151 | 151 | $keep = array(); |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | return $this; |
163 | 163 | } |
164 | 164 | |
165 | - /** |
|
166 | - * Sets the value of a variable, overwriting any existing value. |
|
167 | - * |
|
168 | - * @param string $name |
|
169 | - * @param mixed $value If an array is specified, it is treated as duplicate keys and will add a line for each value. |
|
170 | - * @return IniHelper_Section |
|
171 | - */ |
|
165 | + /** |
|
166 | + * Sets the value of a variable, overwriting any existing value. |
|
167 | + * |
|
168 | + * @param string $name |
|
169 | + * @param mixed $value If an array is specified, it is treated as duplicate keys and will add a line for each value. |
|
170 | + * @return IniHelper_Section |
|
171 | + */ |
|
172 | 172 | public function setValue(string $name, $value) : IniHelper_Section |
173 | 173 | { |
174 | 174 | $lines = $this->getLinesByVariable($name); |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | return $this; |
230 | 230 | } |
231 | 231 | |
232 | - /** |
|
233 | - * Adds a variable value to the section. Unlike setValue(), this |
|
234 | - * will not overwrite any existing value. If the name is an existing |
|
235 | - * variable name, it will be converted to duplicate keys. |
|
236 | - * |
|
237 | - * @param string $name |
|
238 | - * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
239 | - * @return IniHelper_Section |
|
240 | - */ |
|
232 | + /** |
|
233 | + * Adds a variable value to the section. Unlike setValue(), this |
|
234 | + * will not overwrite any existing value. If the name is an existing |
|
235 | + * variable name, it will be converted to duplicate keys. |
|
236 | + * |
|
237 | + * @param string $name |
|
238 | + * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
239 | + * @return IniHelper_Section |
|
240 | + */ |
|
241 | 241 | public function addValue(string $name, $value) : IniHelper_Section |
242 | 242 | { |
243 | 243 | // array value? Treat it as duplicate keys. |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | |
298 | - /** |
|
299 | - * Retrieves all lines for the specified variable name. |
|
300 | - * |
|
301 | - * @param string $name |
|
302 | - * @return \AppUtils\IniHelper_Line[] |
|
303 | - */ |
|
298 | + /** |
|
299 | + * Retrieves all lines for the specified variable name. |
|
300 | + * |
|
301 | + * @param string $name |
|
302 | + * @return \AppUtils\IniHelper_Line[] |
|
303 | + */ |
|
304 | 304 | public function getLinesByVariable(string $name) |
305 | 305 | { |
306 | 306 | $result = array(); |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | { |
87 | 87 | $result = array(); |
88 | 88 | |
89 | - foreach($this->lines as $line) |
|
89 | + foreach ($this->lines as $line) |
|
90 | 90 | { |
91 | - if(!$line->isValue()) { |
|
91 | + if (!$line->isValue()) { |
|
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | |
95 | 95 | $name = $line->getVarName(); |
96 | 96 | |
97 | - if(!isset($result[$name])) |
|
97 | + if (!isset($result[$name])) |
|
98 | 98 | { |
99 | 99 | $result[$name] = $line->getVarValue(); |
100 | 100 | continue; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | // name exists in collection? Then this is a |
104 | 104 | // duplicate key and we need to convert it to |
105 | 105 | // an indexed array of values. |
106 | - if(!is_array($result[$name])) |
|
106 | + if (!is_array($result[$name])) |
|
107 | 107 | { |
108 | 108 | $result[$name] = array($result[$name]); |
109 | 109 | } |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | public function toString() |
123 | 123 | { |
124 | 124 | $lines = array(); |
125 | - if(!$this->isDefault()) |
|
125 | + if (!$this->isDefault()) |
|
126 | 126 | { |
127 | 127 | $lines[] = '['.$this->getName().']'; |
128 | 128 | } |
129 | 129 | |
130 | - foreach($this->lines as $line) |
|
130 | + foreach ($this->lines as $line) |
|
131 | 131 | { |
132 | 132 | // we already did this |
133 | - if($line->isSection()) { |
|
133 | + if ($line->isSection()) { |
|
134 | 134 | continue; |
135 | 135 | } |
136 | 136 | |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | { |
151 | 151 | $keep = array(); |
152 | 152 | |
153 | - foreach($this->lines as $line) |
|
153 | + foreach ($this->lines as $line) |
|
154 | 154 | { |
155 | - if($line !== $toDelete) { |
|
155 | + if ($line !== $toDelete) { |
|
156 | 156 | $keep[] = $line; |
157 | 157 | } |
158 | 158 | } |
@@ -177,23 +177,23 @@ discard block |
||
177 | 177 | // Removes any superfluous values that may |
178 | 178 | // already exist, if there are more than the |
179 | 179 | // new set of values. |
180 | - if(is_array($value)) |
|
180 | + if (is_array($value)) |
|
181 | 181 | { |
182 | 182 | $values = array_values($value); |
183 | 183 | $amountNew = count($values); |
184 | 184 | $amountExisting = count($lines); |
185 | 185 | |
186 | 186 | $max = $amountNew; |
187 | - if($amountExisting > $max) { |
|
187 | + if ($amountExisting > $max) { |
|
188 | 188 | $max = $amountExisting; |
189 | 189 | } |
190 | 190 | |
191 | - for($i=0; $i < $max; $i++) |
|
191 | + for ($i = 0; $i < $max; $i++) |
|
192 | 192 | { |
193 | 193 | // new value exists |
194 | - if(isset($values[$i])) |
|
194 | + if (isset($values[$i])) |
|
195 | 195 | { |
196 | - if(isset($lines[$i])) { |
|
196 | + if (isset($lines[$i])) { |
|
197 | 197 | $lines[$i]->setValue($values[$i]); |
198 | 198 | } else { |
199 | 199 | $this->addValueLine($name, $values[$i]); |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | else |
212 | 212 | { |
213 | 213 | // remove all superfluous lines |
214 | - if(!empty($lines)) |
|
214 | + if (!empty($lines)) |
|
215 | 215 | { |
216 | 216 | $line = array_shift($lines); // keep only the first line |
217 | 217 | $line->setValue($value); |
218 | 218 | |
219 | - foreach($lines as $delete) { |
|
219 | + foreach ($lines as $delete) { |
|
220 | 220 | $this->deleteLine($delete); |
221 | 221 | } |
222 | 222 | } |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | public function addValue(string $name, $value) : IniHelper_Section |
242 | 242 | { |
243 | 243 | // array value? Treat it as duplicate keys. |
244 | - if(is_array($value)) |
|
244 | + if (is_array($value)) |
|
245 | 245 | { |
246 | 246 | $values = array_values($value); |
247 | 247 | |
248 | - foreach($values as $setValue) |
|
248 | + foreach ($values as $setValue) |
|
249 | 249 | { |
250 | 250 | $this->addValue($name, $setValue); |
251 | 251 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | |
256 | 256 | $lines = $this->getLinesByVariable($name); |
257 | 257 | |
258 | - if(empty($lines)) |
|
258 | + if (empty($lines)) |
|
259 | 259 | { |
260 | 260 | $this->addValueLine($name, $value); |
261 | 261 | } |
@@ -263,15 +263,15 @@ discard block |
||
263 | 263 | { |
264 | 264 | $found = false; |
265 | 265 | |
266 | - foreach($lines as $line) |
|
266 | + foreach ($lines as $line) |
|
267 | 267 | { |
268 | - if($line->getVarValue() === $value) { |
|
268 | + if ($line->getVarValue() === $value) { |
|
269 | 269 | $found = $line; |
270 | 270 | break; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | - if(!$found) |
|
274 | + if (!$found) |
|
275 | 275 | { |
276 | 276 | $this->addValueLine($name, $value); |
277 | 277 | } |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | { |
306 | 306 | $result = array(); |
307 | 307 | |
308 | - foreach($this->lines as $line) |
|
308 | + foreach ($this->lines as $line) |
|
309 | 309 | { |
310 | - if($line->isValue() && $line->getVarName() === $name) { |
|
310 | + if ($line->isValue() && $line->getVarName() === $name) { |
|
311 | 311 | $result[] = $line; |
312 | 312 | } |
313 | 313 | } |
@@ -198,8 +198,7 @@ discard block |
||
198 | 198 | } else { |
199 | 199 | $this->addValueLine($name, $values[$i]); |
200 | 200 | } |
201 | - } |
|
202 | - else |
|
201 | + } else |
|
203 | 202 | { |
204 | 203 | $this->deleteLine($lines[$i]); |
205 | 204 | } |
@@ -219,8 +218,7 @@ discard block |
||
219 | 218 | foreach($lines as $delete) { |
220 | 219 | $this->deleteLine($delete); |
221 | 220 | } |
222 | - } |
|
223 | - else |
|
221 | + } else |
|
224 | 222 | { |
225 | 223 | $this->addValueLine($name, $value); |
226 | 224 | } |
@@ -258,8 +256,7 @@ discard block |
||
258 | 256 | if(empty($lines)) |
259 | 257 | { |
260 | 258 | $this->addValueLine($name, $value); |
261 | - } |
|
262 | - else |
|
259 | + } else |
|
263 | 260 | { |
264 | 261 | $found = false; |
265 | 262 |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | protected $file; |
40 | 40 | |
41 | - /** |
|
42 | - * @var \ZipArchive |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var \ZipArchive |
|
43 | + */ |
|
44 | 44 | protected $zip; |
45 | 45 | |
46 | 46 | public function __construct($targetFile) |
@@ -48,33 +48,33 @@ discard block |
||
48 | 48 | $this->file = $targetFile; |
49 | 49 | } |
50 | 50 | |
51 | - /** |
|
52 | - * Sets an option, among the available options: |
|
53 | - * |
|
54 | - * <ul> |
|
55 | - * <li>WriteThreshold: The amount of files to add before the zip is automatically written to disk and re-opened to release the file handles. Set to 0 to disable.</li> |
|
56 | - * </ul> |
|
57 | - * |
|
58 | - * @param string $name |
|
59 | - * @param mixed $value |
|
60 | - * @return ZIPHelper |
|
61 | - */ |
|
51 | + /** |
|
52 | + * Sets an option, among the available options: |
|
53 | + * |
|
54 | + * <ul> |
|
55 | + * <li>WriteThreshold: The amount of files to add before the zip is automatically written to disk and re-opened to release the file handles. Set to 0 to disable.</li> |
|
56 | + * </ul> |
|
57 | + * |
|
58 | + * @param string $name |
|
59 | + * @param mixed $value |
|
60 | + * @return ZIPHelper |
|
61 | + */ |
|
62 | 62 | public function setOption($name, $value) |
63 | 63 | { |
64 | 64 | $this->options[$name] = $value; |
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * Adds a file to the zip. By default, the file is stored |
|
70 | - * with the same name in the root of the zip. Use the optional |
|
71 | - * parameter to change the location in the zip. |
|
72 | - * |
|
73 | - * @param string $filePath |
|
74 | - * @param string $zipPath |
|
75 | - * @throws ZIPHelper_Exception |
|
76 | - * @return bool |
|
77 | - */ |
|
68 | + /** |
|
69 | + * Adds a file to the zip. By default, the file is stored |
|
70 | + * with the same name in the root of the zip. Use the optional |
|
71 | + * parameter to change the location in the zip. |
|
72 | + * |
|
73 | + * @param string $filePath |
|
74 | + * @param string $zipPath |
|
75 | + * @throws ZIPHelper_Exception |
|
76 | + * @return bool |
|
77 | + */ |
|
78 | 78 | public function addFile($filePath, $zipPath=null) |
79 | 79 | { |
80 | 80 | $this->open(); |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | |
253 | 253 | protected $exit; |
254 | 254 | |
255 | - /** |
|
256 | - * Like {@link ZIPHelper::download()}, but deletes the |
|
257 | - * file after sending it to the browser. |
|
258 | - * |
|
259 | - * @param string|NULL $fileName Override the ZIP's file name for the download |
|
260 | - * @see ZIPHelper::download() |
|
261 | - */ |
|
255 | + /** |
|
256 | + * Like {@link ZIPHelper::download()}, but deletes the |
|
257 | + * file after sending it to the browser. |
|
258 | + * |
|
259 | + * @param string|NULL $fileName Override the ZIP's file name for the download |
|
260 | + * @see ZIPHelper::download() |
|
261 | + */ |
|
262 | 262 | public function downloadAndDelete($fileName=null) |
263 | 263 | { |
264 | 264 | $this->exit = false; |
@@ -272,14 +272,14 @@ discard block |
||
272 | 272 | exit; |
273 | 273 | } |
274 | 274 | |
275 | - /** |
|
276 | - * Extracts all files and folders from the zip to the |
|
277 | - * target folder. If no folder is specified, the files |
|
278 | - * are extracted into the same folder as the zip itself. |
|
279 | - * |
|
280 | - * @param string $outputFolder |
|
281 | - * @return boolean |
|
282 | - */ |
|
275 | + /** |
|
276 | + * Extracts all files and folders from the zip to the |
|
277 | + * target folder. If no folder is specified, the files |
|
278 | + * are extracted into the same folder as the zip itself. |
|
279 | + * |
|
280 | + * @param string $outputFolder |
|
281 | + * @return boolean |
|
282 | + */ |
|
283 | 283 | public function extractAll($outputFolder=null) |
284 | 284 | { |
285 | 285 | if(empty($outputFolder)) { |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | |
295 | - /** |
|
296 | - * @return \ZipArchive |
|
297 | - */ |
|
295 | + /** |
|
296 | + * @return \ZipArchive |
|
297 | + */ |
|
298 | 298 | public function getArchive() |
299 | 299 | { |
300 | 300 | $this->open(); |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | return $this->zip; |
303 | 303 | } |
304 | 304 | |
305 | - /** |
|
306 | - * JSON encodes the specified data and adds the json as |
|
307 | - * a file in the ZIP archive. |
|
308 | - * |
|
309 | - * @param mixed $data |
|
310 | - * @param string $zipPath |
|
311 | - * @return boolean |
|
312 | - */ |
|
305 | + /** |
|
306 | + * JSON encodes the specified data and adds the json as |
|
307 | + * a file in the ZIP archive. |
|
308 | + * |
|
309 | + * @param mixed $data |
|
310 | + * @param string $zipPath |
|
311 | + * @return boolean |
|
312 | + */ |
|
313 | 313 | public function addJSON($data, $zipPath) |
314 | 314 | { |
315 | 315 | return $this->addString( |
@@ -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 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @throws ZIPHelper_Exception |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | - public function addFile($filePath, $zipPath=null) |
|
78 | + public function addFile($filePath, $zipPath = null) |
|
79 | 79 | { |
80 | 80 | $this->open(); |
81 | 81 | |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | |
121 | 121 | protected function open() |
122 | 122 | { |
123 | - if($this->open) { |
|
123 | + if ($this->open) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | - if(!isset($this->zip)) { |
|
127 | + if (!isset($this->zip)) { |
|
128 | 128 | $this->zip = new \ZipArchive(); |
129 | 129 | } |
130 | 130 | |
131 | 131 | $flag = null; |
132 | - if(!file_exists($this->file)) { |
|
132 | + if (!file_exists($this->file)) { |
|
133 | 133 | $flag = \ZipArchive::CREATE; |
134 | 134 | } |
135 | 135 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | { |
170 | 170 | $this->fileTracker++; |
171 | 171 | |
172 | - if($this->options['WriteThreshold'] < 1) { |
|
172 | + if ($this->options['WriteThreshold'] < 1) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | 175 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | protected function close() |
184 | 184 | { |
185 | - if(!$this->open) { |
|
185 | + if (!$this->open) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | throw new ZIPHelper_Exception( |
191 | 191 | 'Could not save ZIP file to disk', |
192 | 192 | sprintf( |
193 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
194 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
193 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
194 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
195 | 195 | 'or trying to save to a directory that does not exist.', |
196 | 196 | $this->file |
197 | 197 | ), |
@@ -228,22 +228,22 @@ discard block |
||
228 | 228 | * @see ZIPHelper::downloadAndDelete() |
229 | 229 | * @throws ZIPHelper_Exception |
230 | 230 | */ |
231 | - public function download($fileName=null) |
|
231 | + public function download($fileName = null) |
|
232 | 232 | { |
233 | 233 | $this->save(); |
234 | 234 | |
235 | - if(empty($fileName)) { |
|
235 | + if (empty($fileName)) { |
|
236 | 236 | $fileName = basename($this->file); |
237 | 237 | } |
238 | 238 | |
239 | 239 | header('Content-type: application/zip'); |
240 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
241 | - header('Content-length: ' . filesize($this->file)); |
|
240 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
241 | + header('Content-length: '.filesize($this->file)); |
|
242 | 242 | header('Pragma: no-cache'); |
243 | 243 | header('Expires: 0'); |
244 | 244 | readfile($this->file); |
245 | 245 | |
246 | - if($this->exit === false) { |
|
246 | + if ($this->exit === false) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param string|NULL $fileName Override the ZIP's file name for the download |
260 | 260 | * @see ZIPHelper::download() |
261 | 261 | */ |
262 | - public function downloadAndDelete($fileName=null) |
|
262 | + public function downloadAndDelete($fileName = null) |
|
263 | 263 | { |
264 | 264 | $this->exit = false; |
265 | 265 | |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * @param string $outputFolder |
281 | 281 | * @return boolean |
282 | 282 | */ |
283 | - public function extractAll($outputFolder=null) |
|
283 | + public function extractAll($outputFolder = null) |
|
284 | 284 | { |
285 | - if(empty($outputFolder)) { |
|
285 | + if (empty($outputFolder)) { |
|
286 | 286 | $outputFolder = dirname($this->file); |
287 | 287 | } |
288 | 288 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * The converted string will be all lowercase. |
61 | 61 | * @return Transliteration |
62 | 62 | */ |
63 | - public function setLowercase(bool $lowercase=true) : Transliteration |
|
63 | + public function setLowercase(bool $lowercase = true) : Transliteration |
|
64 | 64 | { |
65 | 65 | $this->setOption('lowercase', true); |
66 | 66 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | |
98 | 98 | $result = implode('', $keep); |
99 | 99 | |
100 | - while (strstr($result, $space . $space)) { |
|
101 | - $result = str_replace($space . $space, $space, $result); |
|
100 | + while (strstr($result, $space.$space)) { |
|
101 | + $result = str_replace($space.$space, $space, $result); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $result = trim($result, $space); |
@@ -443,12 +443,10 @@ discard block |
||
443 | 443 | if($this->isFragment === true) |
444 | 444 | { |
445 | 445 | return '#'.$this->getFragment(); |
446 | - } |
|
447 | - else if($this->isPhone === true) |
|
446 | + } else if($this->isPhone === true) |
|
448 | 447 | { |
449 | 448 | return 'tel://'.$this->getHost(); |
450 | - } |
|
451 | - else if($this->isEmail === true) |
|
449 | + } else if($this->isEmail === true) |
|
452 | 450 | { |
453 | 451 | return 'mailto:'.$this->getPath(); |
454 | 452 | } |
@@ -598,13 +596,11 @@ discard block |
||
598 | 596 | $tooltip, |
599 | 597 | $parts |
600 | 598 | ); |
601 | - } |
|
602 | - else |
|
599 | + } else |
|
603 | 600 | { |
604 | 601 | continue; |
605 | 602 | } |
606 | - } |
|
607 | - else |
|
603 | + } else |
|
608 | 604 | { |
609 | 605 | $tag = sprintf( |
610 | 606 | '<span class="link-param">%s</span>', |
@@ -36,40 +36,40 @@ discard block |
||
36 | 36 | const TYPE_PHONE = 'phone'; |
37 | 37 | const TYPE_URL = 'url'; |
38 | 38 | |
39 | - /** |
|
40 | - * The original URL that was passed to the constructor. |
|
41 | - * @var string |
|
42 | - */ |
|
39 | + /** |
|
40 | + * The original URL that was passed to the constructor. |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $rawURL; |
44 | 44 | |
45 | - /** |
|
46 | - * @var array |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var array |
|
47 | + */ |
|
48 | 48 | protected $info; |
49 | 49 | |
50 | - /** |
|
51 | - * @var bool |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var bool |
|
52 | + */ |
|
53 | 53 | protected $isEmail = false; |
54 | 54 | |
55 | - /** |
|
56 | - * @var bool |
|
57 | - */ |
|
55 | + /** |
|
56 | + * @var bool |
|
57 | + */ |
|
58 | 58 | protected $isFragment = false; |
59 | 59 | |
60 | - /** |
|
61 | - * @var bool |
|
62 | - */ |
|
60 | + /** |
|
61 | + * @var bool |
|
62 | + */ |
|
63 | 63 | protected $isValid = true; |
64 | 64 | |
65 | - /** |
|
66 | - * @var bool |
|
67 | - */ |
|
65 | + /** |
|
66 | + * @var bool |
|
67 | + */ |
|
68 | 68 | protected $isPhone = false; |
69 | 69 | |
70 | - /** |
|
71 | - * @var array |
|
72 | - */ |
|
70 | + /** |
|
71 | + * @var array |
|
72 | + */ |
|
73 | 73 | protected $knownSchemes = array( |
74 | 74 | 'ftp', |
75 | 75 | 'http', |
@@ -80,41 +80,41 @@ discard block |
||
80 | 80 | 'file' |
81 | 81 | ); |
82 | 82 | |
83 | - /** |
|
84 | - * @var array |
|
85 | - */ |
|
83 | + /** |
|
84 | + * @var array |
|
85 | + */ |
|
86 | 86 | protected $error; |
87 | 87 | |
88 | - /** |
|
89 | - * @var array |
|
90 | - */ |
|
88 | + /** |
|
89 | + * @var array |
|
90 | + */ |
|
91 | 91 | protected $params = array(); |
92 | 92 | |
93 | - /** |
|
94 | - * @var string[] |
|
95 | - */ |
|
93 | + /** |
|
94 | + * @var string[] |
|
95 | + */ |
|
96 | 96 | protected $excludedParams = array(); |
97 | 97 | |
98 | - /** |
|
99 | - * @var bool |
|
100 | - * @see URLInfo::setParamExclusion() |
|
101 | - */ |
|
98 | + /** |
|
99 | + * @var bool |
|
100 | + * @see URLInfo::setParamExclusion() |
|
101 | + */ |
|
102 | 102 | protected $paramExclusion = false; |
103 | 103 | |
104 | - /** |
|
105 | - * @var array |
|
106 | - * @see URLInfo::getTypeLabel() |
|
107 | - */ |
|
104 | + /** |
|
105 | + * @var array |
|
106 | + * @see URLInfo::getTypeLabel() |
|
107 | + */ |
|
108 | 108 | protected static $typeLabels; |
109 | 109 | |
110 | - /** |
|
111 | - * @var bool |
|
112 | - */ |
|
110 | + /** |
|
111 | + * @var bool |
|
112 | + */ |
|
113 | 113 | protected $highlightExcluded = false; |
114 | 114 | |
115 | - /** |
|
116 | - * @var array |
|
117 | - */ |
|
115 | + /** |
|
116 | + * @var array |
|
117 | + */ |
|
118 | 118 | protected $infoKeys = array( |
119 | 119 | 'scheme', |
120 | 120 | 'host', |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | 'fragment' |
127 | 127 | ); |
128 | 128 | |
129 | - /** |
|
130 | - * @var string |
|
131 | - */ |
|
129 | + /** |
|
130 | + * @var string |
|
131 | + */ |
|
132 | 132 | protected $url; |
133 | 133 | |
134 | 134 | public function __construct(string $url) |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | $this->isValid = true; |
215 | 215 | } |
216 | 216 | |
217 | - /** |
|
218 | - * Filters an URL: removes control characters and the |
|
219 | - * like to have a clean URL to work with. |
|
220 | - * |
|
221 | - * @param string $url |
|
222 | - * @return string |
|
223 | - */ |
|
217 | + /** |
|
218 | + * Filters an URL: removes control characters and the |
|
219 | + * like to have a clean URL to work with. |
|
220 | + * |
|
221 | + * @param string $url |
|
222 | + * @return string |
|
223 | + */ |
|
224 | 224 | public static function filterURL(string $url) |
225 | 225 | { |
226 | 226 | // fix ampersands if it comes from HTML |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | return $url; |
244 | 244 | } |
245 | 245 | |
246 | - /** |
|
247 | - * Goes through all information in the parse_url result |
|
248 | - * array, and attempts to fix any user errors in formatting |
|
249 | - * that can be recovered from, mostly regarding stray spaces. |
|
250 | - */ |
|
246 | + /** |
|
247 | + * Goes through all information in the parse_url result |
|
248 | + * array, and attempts to fix any user errors in formatting |
|
249 | + * that can be recovered from, mostly regarding stray spaces. |
|
250 | + */ |
|
251 | 251 | protected function filterParsed() |
252 | 252 | { |
253 | 253 | foreach($this->info as $key => $val) |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | return $this->isPhone; |
332 | 332 | } |
333 | 333 | |
334 | - /** |
|
335 | - * Whether the URL is a regular URL, not one of the |
|
336 | - * other types like a phone number or email address. |
|
337 | - * |
|
338 | - * @return bool |
|
339 | - */ |
|
334 | + /** |
|
335 | + * Whether the URL is a regular URL, not one of the |
|
336 | + * other types like a phone number or email address. |
|
337 | + * |
|
338 | + * @return bool |
|
339 | + */ |
|
340 | 340 | public function isURL() : bool |
341 | 341 | { |
342 | 342 | $host = $this->getHost(); |
@@ -348,20 +348,20 @@ discard block |
||
348 | 348 | return $this->isValid; |
349 | 349 | } |
350 | 350 | |
351 | - /** |
|
352 | - * Retrieves the host name, or an empty string if none is present. |
|
353 | - * |
|
354 | - * @return string |
|
355 | - */ |
|
351 | + /** |
|
352 | + * Retrieves the host name, or an empty string if none is present. |
|
353 | + * |
|
354 | + * @return string |
|
355 | + */ |
|
356 | 356 | public function getHost() : string |
357 | 357 | { |
358 | 358 | return $this->getInfoKey('host'); |
359 | 359 | } |
360 | 360 | |
361 | - /** |
|
362 | - * Retrieves the path, or an empty string if none is present. |
|
363 | - * @return string |
|
364 | - */ |
|
361 | + /** |
|
362 | + * Retrieves the path, or an empty string if none is present. |
|
363 | + * @return string |
|
364 | + */ |
|
365 | 365 | public function getPath() : string |
366 | 366 | { |
367 | 367 | return $this->getInfoKey('path'); |
@@ -377,10 +377,10 @@ discard block |
||
377 | 377 | return $this->getInfoKey('scheme'); |
378 | 378 | } |
379 | 379 | |
380 | - /** |
|
381 | - * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
382 | - * @return int |
|
383 | - */ |
|
380 | + /** |
|
381 | + * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
382 | + * @return int |
|
383 | + */ |
|
384 | 384 | public function getPort() : int |
385 | 385 | { |
386 | 386 | $port = $this->getInfoKey('port'); |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | return -1; |
392 | 392 | } |
393 | 393 | |
394 | - /** |
|
395 | - * Retrieves the raw query string, or an empty string if none is present. |
|
396 | - * |
|
397 | - * @return string |
|
398 | - * |
|
399 | - * @see URLInfo::getParams() |
|
400 | - */ |
|
394 | + /** |
|
395 | + * Retrieves the raw query string, or an empty string if none is present. |
|
396 | + * |
|
397 | + * @return string |
|
398 | + * |
|
399 | + * @see URLInfo::getParams() |
|
400 | + */ |
|
401 | 401 | public function getQuery() : string |
402 | 402 | { |
403 | 403 | return $this->getInfoKey('query'); |
@@ -413,20 +413,20 @@ discard block |
||
413 | 413 | return $this->getInfoKey('pass'); |
414 | 414 | } |
415 | 415 | |
416 | - /** |
|
417 | - * Whether the URL contains a port number. |
|
418 | - * @return bool |
|
419 | - */ |
|
416 | + /** |
|
417 | + * Whether the URL contains a port number. |
|
418 | + * @return bool |
|
419 | + */ |
|
420 | 420 | public function hasPort() : bool |
421 | 421 | { |
422 | 422 | return $this->getPort() !== -1; |
423 | 423 | } |
424 | 424 | |
425 | - /** |
|
426 | - * Alias for the hasParams() method. |
|
427 | - * @return bool |
|
428 | - * @see URLInfo::hasParams() |
|
429 | - */ |
|
425 | + /** |
|
426 | + * Alias for the hasParams() method. |
|
427 | + * @return bool |
|
428 | + * @see URLInfo::hasParams() |
|
429 | + */ |
|
430 | 430 | public function hasQuery() : bool |
431 | 431 | { |
432 | 432 | return $this->hasParams(); |
@@ -507,25 +507,25 @@ discard block |
||
507 | 507 | return $normalized; |
508 | 508 | } |
509 | 509 | |
510 | - /** |
|
511 | - * Creates a hash of the URL, which can be used for comparisons. |
|
512 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
513 | - * the same links with a different parameter order will have the |
|
514 | - * same hash. |
|
515 | - * |
|
516 | - * @return string |
|
517 | - */ |
|
510 | + /** |
|
511 | + * Creates a hash of the URL, which can be used for comparisons. |
|
512 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
513 | + * the same links with a different parameter order will have the |
|
514 | + * same hash. |
|
515 | + * |
|
516 | + * @return string |
|
517 | + */ |
|
518 | 518 | public function getHash() |
519 | 519 | { |
520 | 520 | return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized()); |
521 | 521 | } |
522 | 522 | |
523 | - /** |
|
524 | - * Highlights the URL using HTML tags with specific highlighting |
|
525 | - * class names. |
|
526 | - * |
|
527 | - * @return string Will return an empty string if the URL is not valid. |
|
528 | - */ |
|
523 | + /** |
|
524 | + * Highlights the URL using HTML tags with specific highlighting |
|
525 | + * class names. |
|
526 | + * |
|
527 | + * @return string Will return an empty string if the URL is not valid. |
|
528 | + */ |
|
529 | 529 | public function getHighlighted() : string |
530 | 530 | { |
531 | 531 | if(!$this->isValid) { |
@@ -709,15 +709,15 @@ discard block |
||
709 | 709 | return count($params); |
710 | 710 | } |
711 | 711 | |
712 | - /** |
|
713 | - * Retrieves all parameters specified in the url, |
|
714 | - * if any, as an associative array. |
|
715 | - * |
|
716 | - * NOTE: Ignores parameters that have been added |
|
717 | - * to the excluded parameters list. |
|
718 | - * |
|
719 | - * @return array |
|
720 | - */ |
|
712 | + /** |
|
713 | + * Retrieves all parameters specified in the url, |
|
714 | + * if any, as an associative array. |
|
715 | + * |
|
716 | + * NOTE: Ignores parameters that have been added |
|
717 | + * to the excluded parameters list. |
|
718 | + * |
|
719 | + * @return array |
|
720 | + */ |
|
721 | 721 | public function getParams() : array |
722 | 722 | { |
723 | 723 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -734,26 +734,26 @@ discard block |
||
734 | 734 | return $keep; |
735 | 735 | } |
736 | 736 | |
737 | - /** |
|
738 | - * Retrieves the names of all parameters present in the URL, if any. |
|
739 | - * @return string[] |
|
740 | - */ |
|
737 | + /** |
|
738 | + * Retrieves the names of all parameters present in the URL, if any. |
|
739 | + * @return string[] |
|
740 | + */ |
|
741 | 741 | public function getParamNames() : array |
742 | 742 | { |
743 | 743 | $params = $this->getParams(); |
744 | 744 | return array_keys($params); |
745 | 745 | } |
746 | 746 | |
747 | - /** |
|
748 | - * Excludes an URL parameter entirely if present: |
|
749 | - * the parser will act as if the parameter was not |
|
750 | - * even present in the source URL, effectively |
|
751 | - * stripping it. |
|
752 | - * |
|
753 | - * @param string $name |
|
754 | - * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
755 | - * @return URLInfo |
|
756 | - */ |
|
747 | + /** |
|
748 | + * Excludes an URL parameter entirely if present: |
|
749 | + * the parser will act as if the parameter was not |
|
750 | + * even present in the source URL, effectively |
|
751 | + * stripping it. |
|
752 | + * |
|
753 | + * @param string $name |
|
754 | + * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
755 | + * @return URLInfo |
|
756 | + */ |
|
757 | 757 | public function excludeParam(string $name, string $reason) : URLInfo |
758 | 758 | { |
759 | 759 | if(!isset($this->excludedParams[$name])) |
@@ -818,25 +818,25 @@ discard block |
||
818 | 818 | return self::$typeLabels[$this->getType()]; |
819 | 819 | } |
820 | 820 | |
821 | - /** |
|
822 | - * Whether excluded parameters should be highlighted in |
|
823 | - * a different color in the URL when using the |
|
824 | - * {@link URLInfo::getHighlighted()} method. |
|
825 | - * |
|
826 | - * @param bool $highlight |
|
827 | - * @return URLInfo |
|
828 | - */ |
|
821 | + /** |
|
822 | + * Whether excluded parameters should be highlighted in |
|
823 | + * a different color in the URL when using the |
|
824 | + * {@link URLInfo::getHighlighted()} method. |
|
825 | + * |
|
826 | + * @param bool $highlight |
|
827 | + * @return URLInfo |
|
828 | + */ |
|
829 | 829 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
830 | 830 | { |
831 | 831 | $this->highlightExcluded = $highlight; |
832 | 832 | return $this; |
833 | 833 | } |
834 | 834 | |
835 | - /** |
|
836 | - * Returns an array with all relevant URL information. |
|
837 | - * |
|
838 | - * @return array |
|
839 | - */ |
|
835 | + /** |
|
836 | + * Returns an array with all relevant URL information. |
|
837 | + * |
|
838 | + * @return array |
|
839 | + */ |
|
840 | 840 | public function toArray() : array |
841 | 841 | { |
842 | 842 | return array( |
@@ -880,24 +880,24 @@ discard block |
||
880 | 880 | return $this; |
881 | 881 | } |
882 | 882 | |
883 | - /** |
|
884 | - * Whether the parameter exclusion mode is enabled: |
|
885 | - * In this case, if any parameters have been added to the |
|
886 | - * exclusion list, all relevant methods will exclude these. |
|
887 | - * |
|
888 | - * @return bool |
|
889 | - */ |
|
883 | + /** |
|
884 | + * Whether the parameter exclusion mode is enabled: |
|
885 | + * In this case, if any parameters have been added to the |
|
886 | + * exclusion list, all relevant methods will exclude these. |
|
887 | + * |
|
888 | + * @return bool |
|
889 | + */ |
|
890 | 890 | public function isParamExclusionEnabled() : bool |
891 | 891 | { |
892 | 892 | return $this->paramExclusion; |
893 | 893 | } |
894 | 894 | |
895 | - /** |
|
896 | - * Checks whether the link contains any parameters that |
|
897 | - * are on the list of excluded parameters. |
|
898 | - * |
|
899 | - * @return bool |
|
900 | - */ |
|
895 | + /** |
|
896 | + * Checks whether the link contains any parameters that |
|
897 | + * are on the list of excluded parameters. |
|
898 | + * |
|
899 | + * @return bool |
|
900 | + */ |
|
901 | 901 | public function containsExcludedParams() : bool |
902 | 902 | { |
903 | 903 | if(empty($this->excludedParams)) { |
@@ -154,26 +154,26 @@ discard block |
||
154 | 154 | |
155 | 155 | $this->filterParsed(); |
156 | 156 | |
157 | - if($this->detectEmail()) { |
|
157 | + if ($this->detectEmail()) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - if($this->detectFragmentLink()) { |
|
161 | + if ($this->detectFragmentLink()) { |
|
162 | 162 | return; |
163 | 163 | } |
164 | 164 | |
165 | - if($this->detectPhoneLink()) { |
|
165 | + if ($this->detectPhoneLink()) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
169 | - if(!$this->isValid) { |
|
169 | + if (!$this->isValid) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
173 | 173 | // no scheme found: it may be an email address without the mailto: |
174 | 174 | // It can't be a variable, since without the scheme it would already |
175 | 175 | // have been recognized as a vaiable only link. |
176 | - if(!isset($this->info['scheme'])) { |
|
176 | + if (!isset($this->info['scheme'])) { |
|
177 | 177 | $this->setError( |
178 | 178 | self::ERROR_MISSING_SCHEME, |
179 | 179 | t('Cannot determine the link\'s scheme, e.g. %1$s.', 'http') |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | - if(!in_array($this->info['scheme'], $this->knownSchemes)) { |
|
185 | + if (!in_array($this->info['scheme'], $this->knownSchemes)) { |
|
186 | 186 | $this->setError( |
187 | 187 | self::ERROR_INVALID_SCHEME, |
188 | - t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' . |
|
188 | + t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '. |
|
189 | 189 | t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes)) |
190 | 190 | ); |
191 | 191 | $this->isValid = false; |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | // every link needs a host. This case can happen for ex, if |
196 | 196 | // the link starts with a typo with only one slash, like: |
197 | 197 | // "http:/hostname" |
198 | - if(!isset($this->info['host'])) { |
|
198 | + if (!isset($this->info['host'])) { |
|
199 | 199 | $this->setError( |
200 | 200 | self::ERROR_MISSING_HOST, |
201 | - t('Cannot determine the link\'s host name.') . ' ' . |
|
201 | + t('Cannot determine the link\'s host name.').' '. |
|
202 | 202 | t('This usually happens when there\'s a typo somewhere.') |
203 | 203 | ); |
204 | 204 | $this->isValid = false; |
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | - if(!empty($this->info['query'])) |
|
208 | + if (!empty($this->info['query'])) |
|
209 | 209 | { |
210 | 210 | $this->params = \AppUtils\ConvertHelper::parseQueryString($this->info['query']); |
211 | 211 | ksort($this->params); |
@@ -250,30 +250,30 @@ discard block |
||
250 | 250 | */ |
251 | 251 | protected function filterParsed() |
252 | 252 | { |
253 | - foreach($this->info as $key => $val) |
|
253 | + foreach ($this->info as $key => $val) |
|
254 | 254 | { |
255 | - if(is_string($val)) { |
|
255 | + if (is_string($val)) { |
|
256 | 256 | $this->info[$key] = trim($val); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - if(isset($this->info['host'])) { |
|
260 | + if (isset($this->info['host'])) { |
|
261 | 261 | $this->info['host'] = str_replace(' ', '', $this->info['host']); |
262 | 262 | } |
263 | 263 | |
264 | - if(isset($this->info['path'])) { |
|
264 | + if (isset($this->info['path'])) { |
|
265 | 265 | $this->info['path'] = str_replace(' ', '', $this->info['path']); |
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | 269 | protected function detectEmail() |
270 | 270 | { |
271 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
271 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
272 | 272 | $this->isEmail = true; |
273 | 273 | return true; |
274 | 274 | } |
275 | 275 | |
276 | - if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
276 | + if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
277 | 277 | { |
278 | 278 | $this->info['scheme'] = 'email'; |
279 | 279 | $this->isEmail = true; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | |
286 | 286 | protected function detectFragmentLink() |
287 | 287 | { |
288 | - if(isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
288 | + if (isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
289 | 289 | $this->isFragment = true; |
290 | 290 | return true; |
291 | 291 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | protected function detectPhoneLink() |
297 | 297 | { |
298 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
298 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
299 | 299 | $this->isPhone = true; |
300 | 300 | return true; |
301 | 301 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function isSecure() |
311 | 311 | { |
312 | - if(isset($this->info['scheme']) && $this->info['scheme']=='https') { |
|
312 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'https') { |
|
313 | 313 | return true; |
314 | 314 | } |
315 | 315 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | public function getPort() : int |
385 | 385 | { |
386 | 386 | $port = $this->getInfoKey('port'); |
387 | - if(!empty($port)) { |
|
387 | + if (!empty($port)) { |
|
388 | 388 | return (int)$port; |
389 | 389 | } |
390 | 390 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | protected function getInfoKey(string $name) : string |
466 | 466 | { |
467 | - if(isset($this->info[$name])) { |
|
467 | + if (isset($this->info[$name])) { |
|
468 | 468 | return (string)$this->info[$name]; |
469 | 469 | } |
470 | 470 | |
@@ -473,34 +473,34 @@ discard block |
||
473 | 473 | |
474 | 474 | public function getNormalized() : string |
475 | 475 | { |
476 | - if(!$this->isValid) { |
|
476 | + if (!$this->isValid) { |
|
477 | 477 | return ''; |
478 | 478 | } |
479 | 479 | |
480 | - if($this->isFragment === true) |
|
480 | + if ($this->isFragment === true) |
|
481 | 481 | { |
482 | 482 | return '#'.$this->getFragment(); |
483 | 483 | } |
484 | - else if($this->isPhone === true) |
|
484 | + else if ($this->isPhone === true) |
|
485 | 485 | { |
486 | 486 | return 'tel://'.$this->getHost(); |
487 | 487 | } |
488 | - else if($this->isEmail === true) |
|
488 | + else if ($this->isEmail === true) |
|
489 | 489 | { |
490 | 490 | return 'mailto:'.$this->getPath(); |
491 | 491 | } |
492 | 492 | |
493 | 493 | $normalized = $this->info['scheme'].'://'.$this->info['host']; |
494 | - if(isset($this->info['path'])) { |
|
494 | + if (isset($this->info['path'])) { |
|
495 | 495 | $normalized .= $this->info['path']; |
496 | 496 | } |
497 | 497 | |
498 | 498 | $params = $this->getParams(); |
499 | - if(!empty($params)) { |
|
499 | + if (!empty($params)) { |
|
500 | 500 | $normalized .= '?'.http_build_query($params); |
501 | 501 | } |
502 | 502 | |
503 | - if(isset($this->info['fragment'])) { |
|
503 | + if (isset($this->info['fragment'])) { |
|
504 | 504 | $normalized .= '#'.$this->info['fragment']; |
505 | 505 | } |
506 | 506 | |
@@ -528,11 +528,11 @@ discard block |
||
528 | 528 | */ |
529 | 529 | public function getHighlighted() : string |
530 | 530 | { |
531 | - if(!$this->isValid) { |
|
531 | + if (!$this->isValid) { |
|
532 | 532 | return ''; |
533 | 533 | } |
534 | 534 | |
535 | - if($this->isEmail) { |
|
535 | + if ($this->isEmail) { |
|
536 | 536 | return sprintf( |
537 | 537 | '<span class="link-scheme scheme-mailto">mailto:</span>'. |
538 | 538 | '<span class="link-host">%s</span>', |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | ); |
541 | 541 | } |
542 | 542 | |
543 | - if($this->isFragment) { |
|
543 | + if ($this->isFragment) { |
|
544 | 544 | return sprintf( |
545 | 545 | '<span class="link-fragment-sign">#</span>'. |
546 | 546 | '<span class="link-fragment-value">%s</span>', |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | |
551 | 551 | $result = ''; |
552 | 552 | |
553 | - if($this->hasScheme()) |
|
553 | + if ($this->hasScheme()) |
|
554 | 554 | { |
555 | 555 | $result = sprintf( |
556 | 556 | '<span class="link-scheme scheme-%1$s">'. |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | |
563 | 563 | $result .= '<span class="link-component double-slashes">//</span>'; |
564 | 564 | |
565 | - if($this->hasUsername()) |
|
565 | + if ($this->hasUsername()) |
|
566 | 566 | { |
567 | 567 | $result .= sprintf( |
568 | 568 | '<span class="link-credentials">%s</span>'. |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | ); |
575 | 575 | } |
576 | 576 | |
577 | - if($this->hasHost()) |
|
577 | + if ($this->hasHost()) |
|
578 | 578 | { |
579 | 579 | $result .= |
580 | 580 | sprintf( |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | ); |
584 | 584 | } |
585 | 585 | |
586 | - if($this->hasPort()) |
|
586 | + if ($this->hasPort()) |
|
587 | 587 | { |
588 | 588 | $result .= sprintf( |
589 | 589 | '<span class="link-component port-separator">:</span>'. |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | ); |
593 | 593 | } |
594 | 594 | |
595 | - if($this->hasPath()) |
|
595 | + if ($this->hasPath()) |
|
596 | 596 | { |
597 | 597 | $path = str_replace(array(';', '='), array(';<wbr>', '=<wbr>'), $this->getPath()); |
598 | 598 | $tokens = explode('/', $path); |
@@ -603,11 +603,11 @@ discard block |
||
603 | 603 | ); |
604 | 604 | } |
605 | 605 | |
606 | - if(!empty($this->params)) |
|
606 | + if (!empty($this->params)) |
|
607 | 607 | { |
608 | 608 | $tokens = array(); |
609 | 609 | |
610 | - foreach($this->params as $param => $value) |
|
610 | + foreach ($this->params as $param => $value) |
|
611 | 611 | { |
612 | 612 | $parts = sprintf( |
613 | 613 | '<span class="link-param-name">%s</span>'. |
@@ -625,10 +625,10 @@ discard block |
||
625 | 625 | $tag = ''; |
626 | 626 | |
627 | 627 | // is parameter exclusion enabled, and is this an excluded parameter? |
628 | - if($this->paramExclusion && isset($this->excludedParams[$param])) |
|
628 | + if ($this->paramExclusion && isset($this->excludedParams[$param])) |
|
629 | 629 | { |
630 | 630 | // display the excluded parameter, but highlight it |
631 | - if($this->highlightExcluded) |
|
631 | + if ($this->highlightExcluded) |
|
632 | 632 | { |
633 | 633 | $tooltip = $this->excludedParams[$param]; |
634 | 634 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | '<span class="link-component query-sign">?</span>'.implode('<span class="link-component param-separator">&</span>', $tokens); |
659 | 659 | } |
660 | 660 | |
661 | - if(isset($this->info['fragment'])) { |
|
661 | + if (isset($this->info['fragment'])) { |
|
662 | 662 | $result .= sprintf( |
663 | 663 | '<span class="link-fragment-sign">#</span>'. |
664 | 664 | '<span class="link-fragment">%s</span>', |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | |
682 | 682 | public function getErrorMessage() : string |
683 | 683 | { |
684 | - if(isset($this->error)) { |
|
684 | + if (isset($this->error)) { |
|
685 | 685 | return $this->error['message']; |
686 | 686 | } |
687 | 687 | |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | |
691 | 691 | public function getErrorCode() : int |
692 | 692 | { |
693 | - if(isset($this->error)) { |
|
693 | + if (isset($this->error)) { |
|
694 | 694 | return $this->error['code']; |
695 | 695 | } |
696 | 696 | |
@@ -720,13 +720,13 @@ discard block |
||
720 | 720 | */ |
721 | 721 | public function getParams() : array |
722 | 722 | { |
723 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
723 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
724 | 724 | return $this->params; |
725 | 725 | } |
726 | 726 | |
727 | 727 | $keep = array(); |
728 | - foreach($this->params as $name => $value) { |
|
729 | - if(!isset($this->excludedParams[$name])) { |
|
728 | + foreach ($this->params as $name => $value) { |
|
729 | + if (!isset($this->excludedParams[$name])) { |
|
730 | 730 | $keep[$name] = $value; |
731 | 731 | } |
732 | 732 | } |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | */ |
757 | 757 | public function excludeParam(string $name, string $reason) : URLInfo |
758 | 758 | { |
759 | - if(!isset($this->excludedParams[$name])) |
|
759 | + if (!isset($this->excludedParams[$name])) |
|
760 | 760 | { |
761 | 761 | $this->excludedParams[$name] = $reason; |
762 | 762 | $this->setParamExclusion(); |
@@ -777,15 +777,15 @@ discard block |
||
777 | 777 | */ |
778 | 778 | public function getType() : string |
779 | 779 | { |
780 | - if($this->isEmail) { |
|
780 | + if ($this->isEmail) { |
|
781 | 781 | return self::TYPE_EMAIL; |
782 | 782 | } |
783 | 783 | |
784 | - if($this->isFragment) { |
|
784 | + if ($this->isFragment) { |
|
785 | 785 | return self::TYPE_FRAGMENT; |
786 | 786 | } |
787 | 787 | |
788 | - if($this->isPhone) { |
|
788 | + if ($this->isPhone) { |
|
789 | 789 | return self::TYPE_PHONE; |
790 | 790 | } |
791 | 791 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | |
795 | 795 | public function getTypeLabel() : string |
796 | 796 | { |
797 | - if(!isset(self::$typeLabels)) |
|
797 | + if (!isset(self::$typeLabels)) |
|
798 | 798 | { |
799 | 799 | self::$typeLabels = array( |
800 | 800 | self::TYPE_EMAIL => t('Email'), |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | |
807 | 807 | $type = $this->getType(); |
808 | 808 | |
809 | - if(!isset(self::$typeLabels[$type])) |
|
809 | + if (!isset(self::$typeLabels[$type])) |
|
810 | 810 | { |
811 | 811 | throw new BaseException( |
812 | 812 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | * @param bool $highlight |
827 | 827 | * @return URLInfo |
828 | 828 | */ |
829 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
829 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
830 | 830 | { |
831 | 831 | $this->highlightExcluded = $highlight; |
832 | 832 | return $this; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | * @see URLInfo::isParamExclusionEnabled() |
875 | 875 | * @see URLInfo::setHighlightExcluded() |
876 | 876 | */ |
877 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
877 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
878 | 878 | { |
879 | 879 | $this->paramExclusion = $enabled; |
880 | 880 | return $this; |
@@ -900,13 +900,13 @@ discard block |
||
900 | 900 | */ |
901 | 901 | public function containsExcludedParams() : bool |
902 | 902 | { |
903 | - if(empty($this->excludedParams)) { |
|
903 | + if (empty($this->excludedParams)) { |
|
904 | 904 | return false; |
905 | 905 | } |
906 | 906 | |
907 | 907 | $names = array_keys($this->params); |
908 | - foreach($names as $name) { |
|
909 | - if(isset($this->excludedParams[$name])) { |
|
908 | + foreach ($names as $name) { |
|
909 | + if (isset($this->excludedParams[$name])) { |
|
910 | 910 | return true; |
911 | 911 | } |
912 | 912 | } |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | |
923 | 923 | public function offsetSet($offset, $value) |
924 | 924 | { |
925 | - if(in_array($offset, $this->infoKeys)) { |
|
925 | + if (in_array($offset, $this->infoKeys)) { |
|
926 | 926 | $this->info[$offset] = $value; |
927 | 927 | } |
928 | 928 | } |
@@ -939,11 +939,11 @@ discard block |
||
939 | 939 | |
940 | 940 | public function offsetGet($offset) |
941 | 941 | { |
942 | - if($offset === 'port') { |
|
942 | + if ($offset === 'port') { |
|
943 | 943 | return $this->getPort(); |
944 | 944 | } |
945 | 945 | |
946 | - if(in_array($offset, $this->infoKeys)) { |
|
946 | + if (in_array($offset, $this->infoKeys)) { |
|
947 | 947 | return $this->getInfoKey($offset); |
948 | 948 | } |
949 | 949 | |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | { |
955 | 955 | $cssFolder = realpath(__DIR__.'/../css'); |
956 | 956 | |
957 | - if($cssFolder === false) { |
|
957 | + if ($cssFolder === false) { |
|
958 | 958 | throw new BaseException( |
959 | 959 | 'Cannot find package CSS folder.', |
960 | 960 | null, |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | return $this->setOption('separatorChar', $char); |
18 | 18 | } |
19 | 19 | |
20 | - public function setTrailingNewline($useNewline=true) |
|
20 | + public function setTrailingNewline($useNewline = true) |
|
21 | 21 | { |
22 | 22 | return $this->setOption('trailingNewline', $useNewline); |
23 | 23 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $args = $args[0]; |
39 | 39 | } |
40 | 40 | |
41 | - $this->lines[] = '"' . implode('"'.$this->getOption('separatorChar').'"', $args) . '"'; |
|
41 | + $this->lines[] = '"'.implode('"'.$this->getOption('separatorChar').'"', $args).'"'; |
|
42 | 42 | |
43 | 43 | return $this; |
44 | 44 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $csv = implode(PHP_EOL, $this->lines); |
56 | 56 | |
57 | - if($this->getOption('trailingNewline')) { |
|
57 | + if ($this->getOption('trailingNewline')) { |
|
58 | 58 | $csv .= PHP_EOL; |
59 | 59 | } |
60 | 60 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | public function setOption($name, $value) |
67 | 67 | { |
68 | - if(!isset($this->options)) { |
|
68 | + if (!isset($this->options)) { |
|
69 | 69 | $this->options = $this->getDefaultOptions(); |
70 | 70 | } |
71 | 71 | |
@@ -75,20 +75,20 @@ discard block |
||
75 | 75 | |
76 | 76 | public function setOptions($options) |
77 | 77 | { |
78 | - foreach($options as $name => $value) { |
|
78 | + foreach ($options as $name => $value) { |
|
79 | 79 | $this->setOption($name, $value); |
80 | 80 | } |
81 | 81 | |
82 | 82 | return $this; |
83 | 83 | } |
84 | 84 | |
85 | - public function getOption($name, $default=null) |
|
85 | + public function getOption($name, $default = null) |
|
86 | 86 | { |
87 | - if(!isset($this->options)) { |
|
87 | + if (!isset($this->options)) { |
|
88 | 88 | $this->options = $this->getDefaultOptions(); |
89 | 89 | } |
90 | 90 | |
91 | - if(isset($this->options[$name])) { |
|
91 | + if (isset($this->options[$name])) { |
|
92 | 92 | return $this->options[$name]; |
93 | 93 | } |
94 | 94 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | public function hasOption($name) |
99 | 99 | { |
100 | - if(!isset($this->options)) { |
|
100 | + if (!isset($this->options)) { |
|
101 | 101 | $this->options = $this->getDefaultOptions(); |
102 | 102 | } |
103 | 103 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | public function getOptions() |
108 | 108 | { |
109 | - if(!isset($this->options)) { |
|
109 | + if (!isset($this->options)) { |
|
110 | 110 | $this->options = $this->getDefaultOptions(); |
111 | 111 | } |
112 | 112 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | public function isOption($name, $value) |
117 | 117 | { |
118 | - if($this->getOption($name) === $value) { |
|
118 | + if ($this->getOption($name) === $value) { |
|
119 | 119 | return true; |
120 | 120 | } |
121 | 121 |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | |
37 | 37 | protected $classes = array(); |
38 | 38 | |
39 | - /** |
|
40 | - * The namespace detected in the file, if any. |
|
41 | - * @var string |
|
42 | - */ |
|
39 | + /** |
|
40 | + * The namespace detected in the file, if any. |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $namespace = ''; |
44 | 44 | |
45 | - /** |
|
46 | - * @param string $path The path to the PHP file to parse. |
|
47 | - * @throws FileHelper_Exception |
|
48 | - * @see FileHelper::findPHPClasses() |
|
49 | - */ |
|
45 | + /** |
|
46 | + * @param string $path The path to the PHP file to parse. |
|
47 | + * @throws FileHelper_Exception |
|
48 | + * @see FileHelper::findPHPClasses() |
|
49 | + */ |
|
50 | 50 | public function __construct(string $path) |
51 | 51 | { |
52 | 52 | $this->path = realpath($path); |
@@ -66,66 +66,66 @@ discard block |
||
66 | 66 | $this->parseFile(); |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * The name of the namespace of the classes in the file, if any. |
|
71 | - * @return string |
|
72 | - */ |
|
69 | + /** |
|
70 | + * The name of the namespace of the classes in the file, if any. |
|
71 | + * @return string |
|
72 | + */ |
|
73 | 73 | public function getNamespace() : string |
74 | 74 | { |
75 | 75 | return $this->namespace; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Whether the file contains a namespace. |
|
80 | - * @return bool |
|
81 | - */ |
|
78 | + /** |
|
79 | + * Whether the file contains a namespace. |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | 82 | public function hasNamespace() : bool |
83 | 83 | { |
84 | 84 | return !empty($this->namespace); |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * The absolute path to the file. |
|
89 | - * @return string |
|
90 | - */ |
|
87 | + /** |
|
88 | + * The absolute path to the file. |
|
89 | + * @return string |
|
90 | + */ |
|
91 | 91 | public function getPath() : string |
92 | 92 | { |
93 | 93 | return $this->path; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Whether any classes were found in the file. |
|
98 | - * @return bool |
|
99 | - */ |
|
96 | + /** |
|
97 | + * Whether any classes were found in the file. |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | 100 | public function hasClasses() : bool |
101 | 101 | { |
102 | 102 | return !empty($this->classes); |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * The names of the classes that were found in the file (with namespace if any). |
|
107 | - * @return string[] |
|
108 | - */ |
|
105 | + /** |
|
106 | + * The names of the classes that were found in the file (with namespace if any). |
|
107 | + * @return string[] |
|
108 | + */ |
|
109 | 109 | public function getClassNames() : array |
110 | 110 | { |
111 | 111 | return array_keys($this->classes); |
112 | 112 | } |
113 | 113 | |
114 | - /** |
|
115 | - * Retrieves all classes that were detected in the file, |
|
116 | - * which can be used to retrieve more information about |
|
117 | - * them. |
|
118 | - * |
|
119 | - * @return FileHelper_PHPClassInfo_Class[] |
|
120 | - */ |
|
114 | + /** |
|
115 | + * Retrieves all classes that were detected in the file, |
|
116 | + * which can be used to retrieve more information about |
|
117 | + * them. |
|
118 | + * |
|
119 | + * @return FileHelper_PHPClassInfo_Class[] |
|
120 | + */ |
|
121 | 121 | public function getClasses() |
122 | 122 | { |
123 | 123 | return $this->classes; |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * @throws FileHelper_Exception |
|
128 | - */ |
|
126 | + /** |
|
127 | + * @throws FileHelper_Exception |
|
128 | + */ |
|
129 | 129 | protected function parseFile() |
130 | 130 | { |
131 | 131 | $code = file_get_contents($this->path); |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | - /** |
|
184 | - * Strips all whitespace from the string, replacing it with |
|
185 | - * regular spaces (newlines, tabs, etc.). |
|
186 | - * |
|
187 | - * @param string $string |
|
188 | - * @return string |
|
189 | - */ |
|
183 | + /** |
|
184 | + * Strips all whitespace from the string, replacing it with |
|
185 | + * regular spaces (newlines, tabs, etc.). |
|
186 | + * |
|
187 | + * @param string $string |
|
188 | + * @return string |
|
189 | + */ |
|
190 | 190 | protected function stripWhitespace(string $string) : string |
191 | 191 | { |
192 | 192 | return preg_replace('/[\s]/', ' ', $string); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $this->path = realpath($path); |
53 | 53 | |
54 | - if($this->path === false) |
|
54 | + if ($this->path === false) |
|
55 | 55 | { |
56 | 56 | throw new FileHelper_Exception( |
57 | 57 | 'Cannot extract file information: file not found.', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | { |
131 | 131 | $code = file_get_contents($this->path); |
132 | 132 | |
133 | - if($code === false) |
|
133 | + if ($code === false) |
|
134 | 134 | { |
135 | 135 | throw new FileHelper_Exception( |
136 | 136 | 'Cannot open file for parsing.', |
@@ -149,24 +149,24 @@ discard block |
||
149 | 149 | |
150 | 150 | $result = array(); |
151 | 151 | preg_match_all('/namespace[\s]+([^;]+);/six', $code, $result, PREG_PATTERN_ORDER); |
152 | - if(isset($result[0]) && isset($result[0][0])) { |
|
152 | + if (isset($result[0]) && isset($result[0][0])) { |
|
153 | 153 | $this->namespace = trim($result[1][0]); |
154 | 154 | } |
155 | 155 | |
156 | 156 | $result = array(); |
157 | 157 | preg_match_all('/(abstract|final)[\s]+class[\s]+([\sa-z0-9\\\\_,]+){|class[\s]+([\sa-z0-9\\\\_,]+){/six', $code, $result, PREG_PATTERN_ORDER); |
158 | 158 | |
159 | - if(!isset($result[0]) || !isset($result[0][0])) { |
|
159 | + if (!isset($result[0]) || !isset($result[0][0])) { |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | $indexes = array_keys($result[0]); |
164 | 164 | |
165 | - foreach($indexes as $idx) |
|
165 | + foreach ($indexes as $idx) |
|
166 | 166 | { |
167 | 167 | $keyword = $result[1][$idx]; |
168 | 168 | $declaration = $result[2][$idx]; |
169 | - if(empty($keyword)) { |
|
169 | + if (empty($keyword)) { |
|
170 | 170 | $declaration = $result[3][$idx]; |
171 | 171 | } |
172 | 172 |
@@ -147,8 +147,7 @@ discard block |
||
147 | 147 | if($this->getOption('recursive') === true && !$item->isDot()) { |
148 | 148 | $this->find($item->getPathname()); |
149 | 149 | } |
150 | - } |
|
151 | - else |
|
150 | + } else |
|
152 | 151 | { |
153 | 152 | $file = $this->filterFile($item->getPathname()); |
154 | 153 | if($file) { |
@@ -172,8 +171,7 @@ discard block |
||
172 | 171 | if(!in_array($info['extension'], $include)) { |
173 | 172 | return false; |
174 | 173 | } |
175 | - } |
|
176 | - else if(!empty($exclude)) |
|
174 | + } else if(!empty($exclude)) |
|
177 | 175 | { |
178 | 176 | if(in_array($info['extension'], $exclude)) { |
179 | 177 | return false; |
@@ -31,9 +31,9 @@ |
||
31 | 31 | |
32 | 32 | const PATH_MODE_STRIP = 'strip'; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | 37 | protected $path; |
38 | 38 | |
39 | 39 | public function __construct(string $path) |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @see FileHelper_FileFinder |
8 | 8 | */ |
9 | 9 | |
10 | -declare(strict_types = 1); |
|
10 | +declare(strict_types=1); |
|
11 | 11 | |
12 | 12 | namespace AppUtils; |
13 | 13 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | public function getAll() : array |
127 | 127 | { |
128 | - if(!isset($this->found)) { |
|
128 | + if (!isset($this->found)) { |
|
129 | 129 | $this->find($this->path, true); |
130 | 130 | } |
131 | 131 | |
@@ -150,25 +150,25 @@ discard block |
||
150 | 150 | |
151 | 151 | protected $found; |
152 | 152 | |
153 | - protected function find($path, $isRoot=false) |
|
153 | + protected function find($path, $isRoot = false) |
|
154 | 154 | { |
155 | - if($isRoot) { |
|
155 | + if ($isRoot) { |
|
156 | 156 | $this->found = array(); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $d = new \DirectoryIterator($path); |
160 | - foreach($d as $item) |
|
160 | + foreach ($d as $item) |
|
161 | 161 | { |
162 | - if($item->isDir()) |
|
162 | + if ($item->isDir()) |
|
163 | 163 | { |
164 | - if($this->getOption('recursive') === true && !$item->isDot()) { |
|
164 | + if ($this->getOption('recursive') === true && !$item->isDot()) { |
|
165 | 165 | $this->find($item->getPathname()); |
166 | 166 | } |
167 | 167 | } |
168 | 168 | else |
169 | 169 | { |
170 | 170 | $file = $this->filterFile($item->getPathname()); |
171 | - if($file) { |
|
171 | + if ($file) { |
|
172 | 172 | $this->found[] = $file; |
173 | 173 | } |
174 | 174 | } |
@@ -184,20 +184,20 @@ discard block |
||
184 | 184 | $include = $this->getOption('include-extensions'); |
185 | 185 | $exclude = $this->getOption('exclude-extensions'); |
186 | 186 | |
187 | - if(!empty($include)) |
|
187 | + if (!empty($include)) |
|
188 | 188 | { |
189 | - if(!in_array($info['extension'], $include)) { |
|
189 | + if (!in_array($info['extension'], $include)) { |
|
190 | 190 | return false; |
191 | 191 | } |
192 | 192 | } |
193 | - else if(!empty($exclude)) |
|
193 | + else if (!empty($exclude)) |
|
194 | 194 | { |
195 | - if(in_array($info['extension'], $exclude)) { |
|
195 | + if (in_array($info['extension'], $exclude)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - switch($this->getOption('pathmode')) |
|
200 | + switch ($this->getOption('pathmode')) |
|
201 | 201 | { |
202 | 202 | case self::PATH_MODE_STRIP: |
203 | 203 | $path = basename($path); |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | break; |
214 | 214 | } |
215 | 215 | |
216 | - if($this->getOption('strip-extensions') === true) |
|
216 | + if ($this->getOption('strip-extensions') === true) |
|
217 | 217 | { |
218 | 218 | $path = str_replace('.'.$info['extension'], '', $path); |
219 | 219 | } |
220 | 220 | |
221 | 221 | $replace = $this->getOption('slash-replacement'); |
222 | - if(!empty($replace)) { |
|
222 | + if (!empty($replace)) { |
|
223 | 223 | $path = str_replace('/', $replace, $path); |
224 | 224 | } |
225 | 225 |