@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private static function checkFragment(string $fragment) : void |
109 | 109 | { |
110 | - if(!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
|
110 | + if (!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
|
111 | 111 | { |
112 | 112 | return; |
113 | 113 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | // capture all elements except the body tag itself |
209 | 209 | $xml = ''; |
210 | - foreach($nodes as $child) |
|
210 | + foreach ($nodes as $child) |
|
211 | 211 | { |
212 | 212 | $xml .= $this->dom->saveXML($child); |
213 | 213 | } |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | { |
40 | 40 | public const ERROR_STRING_ALREADY_HAS_BODY_TAG = 57001; |
41 | 41 | |
42 | - /** |
|
43 | - * @var \DOMElement |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var \DOMElement |
|
44 | + */ |
|
45 | 45 | private $bodyNode; |
46 | 46 | |
47 | - /** |
|
48 | - * @var XMLHelper_DOMErrors |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var XMLHelper_DOMErrors |
|
49 | + */ |
|
50 | 50 | private $errors; |
51 | 51 | |
52 | - /** |
|
53 | - * @var string |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var string |
|
54 | + */ |
|
55 | 55 | private static $htmlTemplate = |
56 | 56 | '<!DOCTYPE html>'. |
57 | 57 | '<html>'. |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | '</body>'. |
64 | 64 | '</html>'; |
65 | 65 | |
66 | - /** |
|
67 | - * @var \DOMDocument |
|
68 | - */ |
|
66 | + /** |
|
67 | + * @var \DOMDocument |
|
68 | + */ |
|
69 | 69 | private $dom; |
70 | 70 | |
71 | 71 | private function __construct(string $html) |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | $this->load($html); |
74 | 74 | } |
75 | 75 | |
76 | - /** |
|
77 | - * Creates an HTML loader from an HTML fragment (without |
|
78 | - * doctype, head and body elements). |
|
79 | - * |
|
80 | - * @param string $fragment |
|
81 | - * @return XMLHelper_HTMLLoader |
|
82 | - */ |
|
76 | + /** |
|
77 | + * Creates an HTML loader from an HTML fragment (without |
|
78 | + * doctype, head and body elements). |
|
79 | + * |
|
80 | + * @param string $fragment |
|
81 | + * @return XMLHelper_HTMLLoader |
|
82 | + */ |
|
83 | 83 | public static function loadFragment(string $fragment) : XMLHelper_HTMLLoader |
84 | 84 | { |
85 | 85 | self::checkFragment($fragment); |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | return new XMLHelper_HTMLLoader($pseudoHTML); |
91 | 91 | } |
92 | 92 | |
93 | - /** |
|
94 | - * Creates an HTML loader from a full HTML document (including |
|
95 | - * doctype, head and body elements). |
|
96 | - * |
|
97 | - * @param string $html |
|
98 | - * @return XMLHelper_HTMLLoader |
|
99 | - */ |
|
93 | + /** |
|
94 | + * Creates an HTML loader from a full HTML document (including |
|
95 | + * doctype, head and body elements). |
|
96 | + * |
|
97 | + * @param string $html |
|
98 | + * @return XMLHelper_HTMLLoader |
|
99 | + */ |
|
100 | 100 | public static function loadHTML(string $html) : XMLHelper_HTMLLoader |
101 | 101 | { |
102 | 102 | return new XMLHelper_HTMLLoader($html); |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * Verifies that the fragment does not already contain a body element or doctype. |
|
107 | - * |
|
108 | - * @param string $fragment |
|
109 | - * @throws XMLHelper_Exception |
|
110 | - */ |
|
105 | + /** |
|
106 | + * Verifies that the fragment does not already contain a body element or doctype. |
|
107 | + * |
|
108 | + * @param string $fragment |
|
109 | + * @throws XMLHelper_Exception |
|
110 | + */ |
|
111 | 111 | private static function checkFragment(string $fragment) : void |
112 | 112 | { |
113 | 113 | if(!stristr($fragment, '<body') && !stristr($fragment, 'doctype')) |
@@ -145,65 +145,65 @@ discard block |
||
145 | 145 | return $this->bodyNode; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * Retrieves the document's `<body>` tag node. |
|
150 | - * |
|
151 | - * @return \DOMDocument |
|
152 | - */ |
|
148 | + /** |
|
149 | + * Retrieves the document's `<body>` tag node. |
|
150 | + * |
|
151 | + * @return \DOMDocument |
|
152 | + */ |
|
153 | 153 | public function getDOM() : \DOMDocument |
154 | 154 | { |
155 | 155 | return $this->dom; |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * Retrieves all nodes from the HTML fragment (= child nodes |
|
160 | - * of the `<body>` element). |
|
161 | - * |
|
162 | - * @return DOMNodeList<DOMNode> |
|
163 | - */ |
|
158 | + /** |
|
159 | + * Retrieves all nodes from the HTML fragment (= child nodes |
|
160 | + * of the `<body>` element). |
|
161 | + * |
|
162 | + * @return DOMNodeList<DOMNode> |
|
163 | + */ |
|
164 | 164 | public function getFragmentNodes() : DOMNodeList |
165 | 165 | { |
166 | 166 | return $this->bodyNode->childNodes; |
167 | 167 | } |
168 | 168 | |
169 | - /** |
|
170 | - * Retrieves the LibXML HTML parsing errors collection, which |
|
171 | - * can be used to review any errors that occurred while loading |
|
172 | - * the HTML document. |
|
173 | - * |
|
174 | - * @return XMLHelper_DOMErrors |
|
175 | - */ |
|
169 | + /** |
|
170 | + * Retrieves the LibXML HTML parsing errors collection, which |
|
171 | + * can be used to review any errors that occurred while loading |
|
172 | + * the HTML document. |
|
173 | + * |
|
174 | + * @return XMLHelper_DOMErrors |
|
175 | + */ |
|
176 | 176 | public function getErrors() : XMLHelper_DOMErrors |
177 | 177 | { |
178 | 178 | return $this->errors; |
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Returns a valid HTML string. |
|
183 | - * |
|
184 | - * @return string |
|
185 | - */ |
|
181 | + /** |
|
182 | + * Returns a valid HTML string. |
|
183 | + * |
|
184 | + * @return string |
|
185 | + */ |
|
186 | 186 | public function toHTML() : string |
187 | 187 | { |
188 | 188 | return $this->dom->saveHTML(); |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Returns a valid XML string. |
|
193 | - * |
|
194 | - * @return string |
|
195 | - */ |
|
191 | + /** |
|
192 | + * Returns a valid XML string. |
|
193 | + * |
|
194 | + * @return string |
|
195 | + */ |
|
196 | 196 | public function toXML() : string |
197 | 197 | { |
198 | 198 | return $this->dom->saveXML(); |
199 | 199 | } |
200 | 200 | |
201 | - /** |
|
202 | - * Converts the HTML fragment to valid XML (= all |
|
203 | - * child nodes of the `<body>` element). |
|
204 | - * |
|
205 | - * @return string |
|
206 | - */ |
|
201 | + /** |
|
202 | + * Converts the HTML fragment to valid XML (= all |
|
203 | + * child nodes of the `<body>` element). |
|
204 | + * |
|
205 | + * @return string |
|
206 | + */ |
|
207 | 207 | public function fragmentToXML() : string |
208 | 208 | { |
209 | 209 | $nodes = $this->getFragmentNodes(); |
@@ -14,9 +14,9 @@ |
||
14 | 14 | * @see http://www.xmlsoft.org/html/libxml-xmlerror.html |
15 | 15 | */ |
16 | 16 | |
17 | - /** |
|
18 | - * @var string $list |
|
19 | - */ |
|
17 | + /** |
|
18 | + * @var string $list |
|
19 | + */ |
|
20 | 20 | $list = file_get_contents('libxmlerrors.txt'); |
21 | 21 | $outputFile = 'LibXML.php'; |
22 | 22 | $lines = explode("\n", $list); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $lines = explode("\n", $list); |
23 | 23 | $reverseArray = array(); |
24 | 24 | |
25 | - foreach($lines as $line) |
|
25 | + foreach ($lines as $line) |
|
26 | 26 | { |
27 | 27 | $parts = explode('=', $line); |
28 | 28 | $name = trim(str_replace('XML_ERR_', '', $parts[0])); |
@@ -19,9 +19,9 @@ |
||
19 | 19 | */ |
20 | 20 | class Request_RefreshParams_Exclude_Name extends Request_RefreshParams_Exclude |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | private $name; |
26 | 26 | |
27 | 27 | public function __construct(string $paramName) |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param bool $exclude |
49 | 49 | * @return Request_RefreshParams |
50 | 50 | */ |
51 | - public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams |
|
51 | + public function setExcludeSessionName(bool $exclude = true) : Request_RefreshParams |
|
52 | 52 | { |
53 | 53 | $this->setOption('exclude-session-name', $exclude); |
54 | 54 | return $this; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | public function excludeParamByName(string $paramName) : Request_RefreshParams |
72 | 72 | { |
73 | - if($paramName !== '') |
|
73 | + if ($paramName !== '') |
|
74 | 74 | { |
75 | 75 | $this->excludes[] = new Request_RefreshParams_Exclude_Name($paramName); |
76 | 76 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function excludeParamsByName(array $paramNames) : Request_RefreshParams |
109 | 109 | { |
110 | - foreach($paramNames as $name) |
|
110 | + foreach ($paramNames as $name) |
|
111 | 111 | { |
112 | 112 | $this->excludeParamByName((string)$name); |
113 | 113 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function overrideParams(array $params) : Request_RefreshParams |
141 | 141 | { |
142 | - foreach($params as $name => $value) |
|
142 | + foreach ($params as $name => $value) |
|
143 | 143 | { |
144 | 144 | $this->overrideParam((string)$name, $value); |
145 | 145 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | private function autoExcludeSessionName(array &$excludes) : void |
175 | 175 | { |
176 | - if($this->getBoolOption('exclude-session-name')) |
|
176 | + if ($this->getBoolOption('exclude-session-name')) |
|
177 | 177 | { |
178 | 178 | $excludes[] = new Request_RefreshParams_Exclude_Name(session_name()); |
179 | 179 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | private function autoExcludeQuickform(array &$excludes) : void |
189 | 189 | { |
190 | - if($this->getBoolOption('exclude-quickform-submitter')) |
|
190 | + if ($this->getBoolOption('exclude-quickform-submitter')) |
|
191 | 191 | { |
192 | 192 | $excludes[] = new Request_RefreshParams_Exclude_Callback(function(string $paramName) |
193 | 193 | { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | // Note: using this loop instead of array_merge, |
210 | 210 | // because array_merge has weird behavior when |
211 | 211 | // using numeric keys. |
212 | - foreach($this->overrides as $name => $val) |
|
212 | + foreach ($this->overrides as $name => $val) |
|
213 | 213 | { |
214 | 214 | $params[$name] = $val; |
215 | 215 | } |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | { |
228 | 228 | $result = array(); |
229 | 229 | |
230 | - foreach($params as $name => $value) |
|
230 | + foreach ($params as $name => $value) |
|
231 | 231 | { |
232 | 232 | $name = (string)$name; |
233 | 233 | |
234 | - if(!$this->isExcluded($name, $value)) |
|
234 | + if (!$this->isExcluded($name, $value)) |
|
235 | 235 | { |
236 | 236 | $result[$name] = $value; |
237 | 237 | } |
@@ -252,9 +252,9 @@ discard block |
||
252 | 252 | { |
253 | 253 | $excludes = $this->resolveExcludes(); |
254 | 254 | |
255 | - foreach($excludes as $exclude) |
|
255 | + foreach ($excludes as $exclude) |
|
256 | 256 | { |
257 | - if($exclude->isExcluded($paramName, $paramValue)) |
|
257 | + if ($exclude->isExcluded($paramName, $paramValue)) |
|
258 | 258 | { |
259 | 259 | return true; |
260 | 260 | } |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | { |
24 | 24 | use Traits_Optionable; |
25 | 25 | |
26 | - /** |
|
27 | - * @var array<string,mixed> |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var array<string,mixed> |
|
28 | + */ |
|
29 | 29 | private array $overrides = array(); |
30 | 30 | |
31 | - /** |
|
32 | - * @var Request_RefreshParams_Exclude[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var Request_RefreshParams_Exclude[] |
|
33 | + */ |
|
34 | 34 | private array $excludes = array(); |
35 | 35 | |
36 | 36 | public function getDefaultOptions() : array |
@@ -41,27 +41,27 @@ discard block |
||
41 | 41 | ); |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Whether to automatically exclude the session variable |
|
46 | - * from the parameters. |
|
47 | - * |
|
48 | - * @param bool $exclude |
|
49 | - * @return Request_RefreshParams |
|
50 | - */ |
|
44 | + /** |
|
45 | + * Whether to automatically exclude the session variable |
|
46 | + * from the parameters. |
|
47 | + * |
|
48 | + * @param bool $exclude |
|
49 | + * @return Request_RefreshParams |
|
50 | + */ |
|
51 | 51 | public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams |
52 | 52 | { |
53 | 53 | $this->setOption('exclude-session-name', $exclude); |
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * Whether to automatically exclude the HTML_QuickForm2 |
|
59 | - * request variable used to track whether a form has been |
|
60 | - * submitted. |
|
61 | - * |
|
62 | - * @param bool $exclude |
|
63 | - * @return Request_RefreshParams |
|
64 | - */ |
|
57 | + /** |
|
58 | + * Whether to automatically exclude the HTML_QuickForm2 |
|
59 | + * request variable used to track whether a form has been |
|
60 | + * submitted. |
|
61 | + * |
|
62 | + * @param bool $exclude |
|
63 | + * @return Request_RefreshParams |
|
64 | + */ |
|
65 | 65 | public function setExcludeQuickform(bool $exclude) : Request_RefreshParams |
66 | 66 | { |
67 | 67 | $this->setOption('exclude-quickform-submitter', $exclude); |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Excludes a request parameter by name. |
|
104 | - * |
|
105 | - * @param array<int,string|number> $paramNames |
|
106 | - * @return Request_RefreshParams |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Excludes a request parameter by name. |
|
104 | + * |
|
105 | + * @param array<int,string|number> $paramNames |
|
106 | + * @return Request_RefreshParams |
|
107 | + */ |
|
108 | 108 | public function excludeParamsByName(array $paramNames) : Request_RefreshParams |
109 | 109 | { |
110 | 110 | foreach($paramNames as $name) |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | return $this; |
116 | 116 | } |
117 | 117 | |
118 | - /** |
|
119 | - * Overrides a parameter: even if it exists, this |
|
120 | - * value will be used instead - even if it is on |
|
121 | - * the list of excluded parameters. |
|
122 | - * |
|
123 | - * @param string $paramName |
|
124 | - * @param mixed $paramValue |
|
125 | - * @return Request_RefreshParams |
|
126 | - */ |
|
118 | + /** |
|
119 | + * Overrides a parameter: even if it exists, this |
|
120 | + * value will be used instead - even if it is on |
|
121 | + * the list of excluded parameters. |
|
122 | + * |
|
123 | + * @param string $paramName |
|
124 | + * @param mixed $paramValue |
|
125 | + * @return Request_RefreshParams |
|
126 | + */ |
|
127 | 127 | public function overrideParam(string $paramName, $paramValue) : Request_RefreshParams |
128 | 128 | { |
129 | 129 | $this->overrides[$paramName] = $paramValue; |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | return $this; |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Overrides an array of parameters. |
|
136 | - * |
|
137 | - * @param array<string|number,mixed> $params |
|
138 | - * @return Request_RefreshParams |
|
139 | - */ |
|
134 | + /** |
|
135 | + * Overrides an array of parameters. |
|
136 | + * |
|
137 | + * @param array<string|number,mixed> $params |
|
138 | + * @return Request_RefreshParams |
|
139 | + */ |
|
140 | 140 | public function overrideParams(array $params) : Request_RefreshParams |
141 | 141 | { |
142 | 142 | foreach($params as $name => $value) |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | return $this; |
148 | 148 | } |
149 | 149 | |
150 | - /** |
|
151 | - * Resolves all the parameter exclusions that should |
|
152 | - * be applied to the list of parameters. This includes |
|
153 | - * the manually added exclusions and the dynamic exclusions |
|
154 | - * like the session name. |
|
155 | - * |
|
156 | - * @return Request_RefreshParams_Exclude[] |
|
157 | - */ |
|
150 | + /** |
|
151 | + * Resolves all the parameter exclusions that should |
|
152 | + * be applied to the list of parameters. This includes |
|
153 | + * the manually added exclusions and the dynamic exclusions |
|
154 | + * like the session name. |
|
155 | + * |
|
156 | + * @return Request_RefreshParams_Exclude[] |
|
157 | + */ |
|
158 | 158 | private function resolveExcludes() : array |
159 | 159 | { |
160 | 160 | $excludes = $this->excludes; |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | return $excludes; |
166 | 166 | } |
167 | 167 | |
168 | - /** |
|
169 | - * Automatically excludes the session name from the |
|
170 | - * parameters, if present. |
|
171 | - * |
|
172 | - * @param Request_RefreshParams_Exclude[] $excludes |
|
173 | - */ |
|
168 | + /** |
|
169 | + * Automatically excludes the session name from the |
|
170 | + * parameters, if present. |
|
171 | + * |
|
172 | + * @param Request_RefreshParams_Exclude[] $excludes |
|
173 | + */ |
|
174 | 174 | private function autoExcludeSessionName(array &$excludes) : void |
175 | 175 | { |
176 | 176 | if($this->getBoolOption('exclude-session-name')) |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Automatically excludes the HTML_QuickForm2 submit |
|
184 | - * tracking variable, when enabled. |
|
185 | - * |
|
186 | - * @param Request_RefreshParams_Exclude[] $excludes |
|
187 | - */ |
|
182 | + /** |
|
183 | + * Automatically excludes the HTML_QuickForm2 submit |
|
184 | + * tracking variable, when enabled. |
|
185 | + * |
|
186 | + * @param Request_RefreshParams_Exclude[] $excludes |
|
187 | + */ |
|
188 | 188 | private function autoExcludeQuickform(array &$excludes) : void |
189 | 189 | { |
190 | 190 | if($this->getBoolOption('exclude-quickform-submitter')) |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - /** |
|
200 | - * Retrieves the list of parameters matching the |
|
201 | - * current settings. |
|
202 | - * |
|
203 | - * @return array<string,mixed> |
|
204 | - */ |
|
199 | + /** |
|
200 | + * Retrieves the list of parameters matching the |
|
201 | + * current settings. |
|
202 | + * |
|
203 | + * @return array<string,mixed> |
|
204 | + */ |
|
205 | 205 | public function getParams() : array |
206 | 206 | { |
207 | 207 | $params = $this->removeExcluded($_REQUEST); |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | return $params; |
218 | 218 | } |
219 | 219 | |
220 | - /** |
|
221 | - * Removes all excluded parameters from the array. |
|
222 | - * |
|
223 | - * @param array<string,mixed> $params |
|
224 | - * @return array<string,mixed> |
|
225 | - */ |
|
220 | + /** |
|
221 | + * Removes all excluded parameters from the array. |
|
222 | + * |
|
223 | + * @param array<string,mixed> $params |
|
224 | + * @return array<string,mixed> |
|
225 | + */ |
|
226 | 226 | private function removeExcluded(array $params) : array |
227 | 227 | { |
228 | 228 | $result = array(); |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | return $result; |
241 | 241 | } |
242 | 242 | |
243 | - /** |
|
244 | - * Checks all configured exclusions to see if the |
|
245 | - * parameter should be excluded or not. |
|
246 | - * |
|
247 | - * @param string $paramName |
|
248 | - * @param mixed $paramValue |
|
249 | - * @return bool |
|
250 | - */ |
|
243 | + /** |
|
244 | + * Checks all configured exclusions to see if the |
|
245 | + * parameter should be excluded or not. |
|
246 | + * |
|
247 | + * @param string $paramName |
|
248 | + * @param mixed $paramValue |
|
249 | + * @return bool |
|
250 | + */ |
|
251 | 251 | public function isExcluded(string $paramName, $paramValue) : bool |
252 | 252 | { |
253 | 253 | $excludes = $this->resolveExcludes(); |
@@ -261,8 +261,7 @@ |
||
261 | 261 | $curlCode, |
262 | 262 | curl_error($ch).' | Explanation: '.curl_strerror($curlCode) |
263 | 263 | ); |
264 | - } |
|
265 | - else |
|
264 | + } else |
|
266 | 265 | { |
267 | 266 | $this->response->setBody((string)$output); |
268 | 267 | } |
@@ -44,19 +44,19 @@ discard block |
||
44 | 44 | protected int $contentLength = 0; |
45 | 45 | |
46 | 46 | /** |
47 | - * @var array<string,string> |
|
48 | - */ |
|
47 | + * @var array<string,string> |
|
48 | + */ |
|
49 | 49 | protected $headers = array(); |
50 | 50 | |
51 | - /** |
|
52 | - * @var resource|NULL |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var resource|NULL |
|
53 | + */ |
|
54 | 54 | protected $logfilePointer; |
55 | 55 | |
56 | - /** |
|
57 | - * Creates a new request helper to send POST data to the specified destination URL. |
|
58 | - * @param string $destinationURL |
|
59 | - */ |
|
56 | + /** |
|
57 | + * Creates a new request helper to send POST data to the specified destination URL. |
|
58 | + * @param string $destinationURL |
|
59 | + */ |
|
60 | 60 | public function __construct(string $destinationURL) |
61 | 61 | { |
62 | 62 | $this->destination = $destinationURL; |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | return $this->eol; |
80 | 80 | } |
81 | 81 | |
82 | - /** |
|
83 | - * Sets the timeout for the request, in seconds. If the request |
|
84 | - * takes longer, it will be cancelled and an exception triggered. |
|
85 | - * |
|
86 | - * @param int $seconds |
|
87 | - * @return RequestHelper |
|
88 | - */ |
|
82 | + /** |
|
83 | + * Sets the timeout for the request, in seconds. If the request |
|
84 | + * takes longer, it will be cancelled and an exception triggered. |
|
85 | + * |
|
86 | + * @param int $seconds |
|
87 | + * @return RequestHelper |
|
88 | + */ |
|
89 | 89 | public function setTimeout(int $seconds) : RequestHelper |
90 | 90 | { |
91 | 91 | $this->timeout = $seconds; |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | return $this->timeout; |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * Enables verbose logging of the CURL request, which |
|
103 | - * is then redirected to the target file. |
|
104 | - * |
|
105 | - * @param string $targetFile |
|
106 | - * @return RequestHelper |
|
107 | - */ |
|
101 | + /** |
|
102 | + * Enables verbose logging of the CURL request, which |
|
103 | + * is then redirected to the target file. |
|
104 | + * |
|
105 | + * @param string $targetFile |
|
106 | + * @return RequestHelper |
|
107 | + */ |
|
108 | 108 | public function enableLogging(string $targetFile) : RequestHelper |
109 | 109 | { |
110 | 110 | $this->logfile = $targetFile; |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | return $this; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Adds a file to be sent with the request. |
|
117 | - * |
|
118 | - * @param string $varName The variable name to send the file in |
|
119 | - * @param string $fileName The name of the file as it should be received at the destination |
|
120 | - * @param string $content The raw content of the file |
|
121 | - * @param string $contentType The content type, use the constants to specify this |
|
122 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
123 | - */ |
|
115 | + /** |
|
116 | + * Adds a file to be sent with the request. |
|
117 | + * |
|
118 | + * @param string $varName The variable name to send the file in |
|
119 | + * @param string $fileName The name of the file as it should be received at the destination |
|
120 | + * @param string $content The raw content of the file |
|
121 | + * @param string $contentType The content type, use the constants to specify this |
|
122 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
123 | + */ |
|
124 | 124 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper |
125 | 125 | { |
126 | 126 | $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding); |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | return $this; |
159 | 159 | } |
160 | 160 | |
161 | - /** |
|
162 | - * Sets an HTTP header to include in the request. |
|
163 | - * |
|
164 | - * @param string $name |
|
165 | - * @param string $value |
|
166 | - * @return RequestHelper |
|
167 | - */ |
|
161 | + /** |
|
162 | + * Sets an HTTP header to include in the request. |
|
163 | + * |
|
164 | + * @param string $name |
|
165 | + * @param string $value |
|
166 | + * @return RequestHelper |
|
167 | + */ |
|
168 | 168 | public function setHeader(string $name, string $value) : RequestHelper |
169 | 169 | { |
170 | 170 | $this->headers[$name] = $value; |
@@ -172,31 +172,31 @@ discard block |
||
172 | 172 | return $this; |
173 | 173 | } |
174 | 174 | |
175 | - /** |
|
176 | - * Disables SSL certificate checking. |
|
177 | - * |
|
178 | - * @return RequestHelper |
|
179 | - */ |
|
175 | + /** |
|
176 | + * Disables SSL certificate checking. |
|
177 | + * |
|
178 | + * @return RequestHelper |
|
179 | + */ |
|
180 | 180 | public function disableSSLChecks() : RequestHelper |
181 | 181 | { |
182 | 182 | $this->verifySSL = false; |
183 | 183 | return $this; |
184 | 184 | } |
185 | 185 | |
186 | - /** |
|
187 | - * Sends the POST request to the destination, and returns |
|
188 | - * the response text. |
|
189 | - * |
|
190 | - * The response object is stored internally, so after calling |
|
191 | - * this method it may be retrieved at any moment using the |
|
192 | - * {@link getResponse()} method. |
|
193 | - * |
|
194 | - * @return string |
|
195 | - * @see RequestHelper::getResponse() |
|
196 | - * @throws RequestHelper_Exception |
|
197 | - * |
|
198 | - * @see RequestHelper::ERROR_REQUEST_FAILED |
|
199 | - */ |
|
186 | + /** |
|
187 | + * Sends the POST request to the destination, and returns |
|
188 | + * the response text. |
|
189 | + * |
|
190 | + * The response object is stored internally, so after calling |
|
191 | + * this method it may be retrieved at any moment using the |
|
192 | + * {@link getResponse()} method. |
|
193 | + * |
|
194 | + * @return string |
|
195 | + * @see RequestHelper::getResponse() |
|
196 | + * @throws RequestHelper_Exception |
|
197 | + * |
|
198 | + * @see RequestHelper::ERROR_REQUEST_FAILED |
|
199 | + */ |
|
200 | 200 | public function send() : string |
201 | 201 | { |
202 | 202 | $info = parseURL($this->destination); |
@@ -236,26 +236,26 @@ discard block |
||
236 | 236 | return $this->response->getResponseBody(); |
237 | 237 | } |
238 | 238 | |
239 | - /** |
|
240 | - * Retrieves the request's body content. This is an alias |
|
241 | - * for {@see RequestHelper::getMimeBody()}. |
|
242 | - * |
|
243 | - * @return string |
|
244 | - * @see RequestHelper::getMimeBody() |
|
245 | - */ |
|
239 | + /** |
|
240 | + * Retrieves the request's body content. This is an alias |
|
241 | + * for {@see RequestHelper::getMimeBody()}. |
|
242 | + * |
|
243 | + * @return string |
|
244 | + * @see RequestHelper::getMimeBody() |
|
245 | + */ |
|
246 | 246 | public function getBody() : string |
247 | 247 | { |
248 | 248 | return $this->getMimeBody(); |
249 | 249 | } |
250 | 250 | |
251 | - /** |
|
252 | - * Creates a new CURL resource configured according to the |
|
253 | - * request's settings. |
|
254 | - * |
|
255 | - * @param URLInfo $url |
|
256 | - * @throws RequestHelper_Exception |
|
257 | - * @return resource |
|
258 | - */ |
|
251 | + /** |
|
252 | + * Creates a new CURL resource configured according to the |
|
253 | + * request's settings. |
|
254 | + * |
|
255 | + * @param URLInfo $url |
|
256 | + * @throws RequestHelper_Exception |
|
257 | + * @return resource |
|
258 | + */ |
|
259 | 259 | protected function createCURL(URLInfo $url) |
260 | 260 | { |
261 | 261 | $ch = curl_init(); |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | return true; |
335 | 335 | } |
336 | 336 | |
337 | - /** |
|
338 | - * Compiles the associative headers array into |
|
339 | - * the format understood by CURL, namely an indexed |
|
340 | - * array with one header string per entry. |
|
341 | - * |
|
342 | - * @return string[] |
|
343 | - */ |
|
337 | + /** |
|
338 | + * Compiles the associative headers array into |
|
339 | + * the format understood by CURL, namely an indexed |
|
340 | + * array with one header string per entry. |
|
341 | + * |
|
342 | + * @return string[] |
|
343 | + */ |
|
344 | 344 | protected function renderHeaders() : array |
345 | 345 | { |
346 | 346 | $result = array(); |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | return $result; |
355 | 355 | } |
356 | 356 | |
357 | - /** |
|
358 | - * Retrieves the raw response header, in the form of an indexed |
|
359 | - * array containing all response header lines. |
|
360 | - * |
|
361 | - * @return string[] |
|
362 | - */ |
|
357 | + /** |
|
358 | + * Retrieves the raw response header, in the form of an indexed |
|
359 | + * array containing all response header lines. |
|
360 | + * |
|
361 | + * @return string[] |
|
362 | + */ |
|
363 | 363 | public function getResponseHeader() : array |
364 | 364 | { |
365 | 365 | $response = $this->getResponse(); |
@@ -371,33 +371,33 @@ discard block |
||
371 | 371 | return array(); |
372 | 372 | } |
373 | 373 | |
374 | - /** |
|
375 | - * After calling the {@link send()} method, this may be used to |
|
376 | - * retrieve the response text from the POST request. |
|
377 | - * |
|
378 | - * @return RequestHelper_Response|NULL |
|
379 | - */ |
|
374 | + /** |
|
375 | + * After calling the {@link send()} method, this may be used to |
|
376 | + * retrieve the response text from the POST request. |
|
377 | + * |
|
378 | + * @return RequestHelper_Response|NULL |
|
379 | + */ |
|
380 | 380 | public function getResponse() : ?RequestHelper_Response |
381 | 381 | { |
382 | 382 | return $this->response; |
383 | 383 | } |
384 | 384 | |
385 | - /** |
|
386 | - * Retrieves all headers set until now. |
|
387 | - * |
|
388 | - * @return array<string,string> |
|
389 | - */ |
|
385 | + /** |
|
386 | + * Retrieves all headers set until now. |
|
387 | + * |
|
388 | + * @return array<string,string> |
|
389 | + */ |
|
390 | 390 | public function getHeaders() : array |
391 | 391 | { |
392 | 392 | return $this->headers; |
393 | 393 | } |
394 | 394 | |
395 | - /** |
|
396 | - * Retrieves the value of a header by its name. |
|
397 | - * |
|
398 | - * @param string $name |
|
399 | - * @return string The header value, or an empty string if not set. |
|
400 | - */ |
|
395 | + /** |
|
396 | + * Retrieves the value of a header by its name. |
|
397 | + * |
|
398 | + * @param string $name |
|
399 | + * @return string The header value, or an empty string if not set. |
|
400 | + */ |
|
401 | 401 | public function getHeader(string $name) : string |
402 | 402 | { |
403 | 403 | return $this->headers[$name] ?? ''; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $output = curl_exec($ch); |
207 | 207 | |
208 | - if(isset($this->logfilePointer)) |
|
208 | + if (isset($this->logfilePointer)) |
|
209 | 209 | { |
210 | 210 | fclose($this->logfilePointer); |
211 | 211 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | // CURL will complain about an empty response when the |
218 | 218 | // server sends a 100-continue code. That should not be |
219 | 219 | // regarded as an error. |
220 | - if($output === false && $this->response->getCode() !== 100) |
|
220 | + if ($output === false && $this->response->getCode() !== 100) |
|
221 | 221 | { |
222 | 222 | $curlCode = curl_errno($ch); |
223 | 223 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | { |
261 | 261 | $ch = curl_init(); |
262 | 262 | |
263 | - if(!is_resource($ch)) |
|
263 | + if (!is_resource($ch)) |
|
264 | 264 | { |
265 | 265 | throw new RequestHelper_Exception( |
266 | 266 | 'Could not initialize a new cURL instance.', |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | } |
271 | 271 | |
272 | 272 | $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength()); |
273 | - $this->setHeader('Content-Type', 'multipart/form-data; boundary=' . $this->mimeBoundary); |
|
273 | + $this->setHeader('Content-Type', 'multipart/form-data; boundary='.$this->mimeBoundary); |
|
274 | 274 | |
275 | 275 | curl_setopt($ch, CURLOPT_POST, true); |
276 | 276 | curl_setopt($ch, CURLOPT_URL, $url->getNormalizedWithoutAuth()); |
@@ -283,18 +283,18 @@ discard block |
||
283 | 283 | |
284 | 284 | $loggingEnabled = $this->configureLogging($ch); |
285 | 285 | |
286 | - if(!$loggingEnabled) |
|
286 | + if (!$loggingEnabled) |
|
287 | 287 | { |
288 | 288 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
289 | 289 | } |
290 | 290 | |
291 | - if($this->verifySSL) |
|
291 | + if ($this->verifySSL) |
|
292 | 292 | { |
293 | 293 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
294 | 294 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
295 | 295 | } |
296 | 296 | |
297 | - if($url->hasUsername()) |
|
297 | + if ($url->hasUsername()) |
|
298 | 298 | { |
299 | 299 | curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername()); |
300 | 300 | curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword()); |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | */ |
311 | 311 | protected function configureLogging($ch) : bool |
312 | 312 | { |
313 | - if(empty($this->logfile)) |
|
313 | + if (empty($this->logfile)) |
|
314 | 314 | { |
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
318 | 318 | $res = fopen($this->logfile, 'wb+'); |
319 | 319 | |
320 | - if($res === false) |
|
320 | + if ($res === false) |
|
321 | 321 | { |
322 | 322 | throw new RequestHelper_Exception( |
323 | 323 | 'Cannot open logfile for writing.', |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | |
348 | 348 | $this->setHeader('Expect', ''); |
349 | 349 | |
350 | - foreach($this->headers as $name => $value) { |
|
350 | + foreach ($this->headers as $name => $value) { |
|
351 | 351 | $result[] = $name.': '.$value; |
352 | 352 | } |
353 | 353 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | { |
365 | 365 | $response = $this->getResponse(); |
366 | 366 | |
367 | - if($response !== null) { |
|
367 | + if ($response !== null) { |
|
368 | 368 | return $response->getHeaders(); |
369 | 369 | } |
370 | 370 |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public static function json($subject) : string |
110 | 110 | { |
111 | - if(!is_string($subject)) |
|
111 | + if (!is_string($subject)) |
|
112 | 112 | { |
113 | 113 | $subject = json_encode($subject, JSON_PRETTY_PRINT); |
114 | 114 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @param bool $formatSource Whether to format the source with indentation to make it readable. |
126 | 126 | * @return string |
127 | 127 | */ |
128 | - public static function xml(string $xml, bool $formatSource=false) : string |
|
128 | + public static function xml(string $xml, bool $formatSource = false) : string |
|
129 | 129 | { |
130 | - if($formatSource) |
|
130 | + if ($formatSource) |
|
131 | 131 | { |
132 | 132 | $dom = new DOMDocument(); |
133 | 133 | $dom->preserveWhiteSpace = false; |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param bool $formatSource |
149 | 149 | * @return string |
150 | 150 | */ |
151 | - public static function html(string $html, bool $formatSource=false) : string |
|
151 | + public static function html(string $html, bool $formatSource = false) : string |
|
152 | 152 | { |
153 | - if($formatSource) |
|
153 | + if ($formatSource) |
|
154 | 154 | { |
155 | 155 | $dom = new DOMDocument(); |
156 | 156 | $dom->preserveWhiteSpace = false; |
@@ -41,71 +41,71 @@ discard block |
||
41 | 41 | */ |
42 | 42 | class Highlighter |
43 | 43 | { |
44 | - /** |
|
45 | - * Creates a new GeSHi instance from a source code string. |
|
46 | - * |
|
47 | - * @param string $sourceCode |
|
48 | - * @param string $format |
|
49 | - * @return GeSHi |
|
50 | - */ |
|
44 | + /** |
|
45 | + * Creates a new GeSHi instance from a source code string. |
|
46 | + * |
|
47 | + * @param string $sourceCode |
|
48 | + * @param string $format |
|
49 | + * @return GeSHi |
|
50 | + */ |
|
51 | 51 | public static function fromString(string $sourceCode, string $format) : GeSHi |
52 | 52 | { |
53 | 53 | return new GeSHi($sourceCode, $format); |
54 | 54 | } |
55 | 55 | |
56 | - /** |
|
57 | - * Creates a new GeSHi instance from the contents of a file. |
|
58 | - * |
|
59 | - * @param string $path |
|
60 | - * @param string $format |
|
61 | - * @return GeSHi |
|
62 | - */ |
|
56 | + /** |
|
57 | + * Creates a new GeSHi instance from the contents of a file. |
|
58 | + * |
|
59 | + * @param string $path |
|
60 | + * @param string $format |
|
61 | + * @return GeSHi |
|
62 | + */ |
|
63 | 63 | public static function fromFile(string $path, string $format) : GeSHi |
64 | 64 | { |
65 | 65 | return self::fromString(FileHelper::readContents($path), $format); |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * Parses and highlights the target string. |
|
70 | - * |
|
71 | - * @param string $sourceCode |
|
72 | - * @param string $format |
|
73 | - * @return string |
|
74 | - */ |
|
68 | + /** |
|
69 | + * Parses and highlights the target string. |
|
70 | + * |
|
71 | + * @param string $sourceCode |
|
72 | + * @param string $format |
|
73 | + * @return string |
|
74 | + */ |
|
75 | 75 | public static function parseString(string $sourceCode, string $format) : string |
76 | 76 | { |
77 | 77 | return self::fromString($sourceCode, $format)->parse_code(); |
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * Parses and highlights the contents of the target file. |
|
82 | - * |
|
83 | - * @param string $path |
|
84 | - * @param string $format |
|
85 | - * @return string |
|
86 | - */ |
|
80 | + /** |
|
81 | + * Parses and highlights the contents of the target file. |
|
82 | + * |
|
83 | + * @param string $path |
|
84 | + * @param string $format |
|
85 | + * @return string |
|
86 | + */ |
|
87 | 87 | public static function parseFile(string $path, string $format) : string |
88 | 88 | { |
89 | 89 | return self::fromFile($path, $format)->parse_code(); |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * Adds HTML syntax highlighting to the specified SQL string. |
|
94 | - * |
|
95 | - * @param string $sql |
|
96 | - * @return string |
|
97 | - */ |
|
92 | + /** |
|
93 | + * Adds HTML syntax highlighting to the specified SQL string. |
|
94 | + * |
|
95 | + * @param string $sql |
|
96 | + * @return string |
|
97 | + */ |
|
98 | 98 | public static function sql(string $sql) : string |
99 | 99 | { |
100 | 100 | return self::parseString($sql, 'sql'); |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Adds HTML syntax highlighting to a JSON string, or a data array/object. |
|
105 | - * |
|
106 | - * @param array<int|string,mixed>|object|string $subject A JSON string, or data array/object to convert to JSON to highlight. |
|
107 | - * @return string |
|
108 | - */ |
|
103 | + /** |
|
104 | + * Adds HTML syntax highlighting to a JSON string, or a data array/object. |
|
105 | + * |
|
106 | + * @param array<int|string,mixed>|object|string $subject A JSON string, or data array/object to convert to JSON to highlight. |
|
107 | + * @return string |
|
108 | + */ |
|
109 | 109 | public static function json($subject) : string |
110 | 110 | { |
111 | 111 | if(!is_string($subject)) |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | return self::parseString($subject, 'javascript'); |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Adds HTML syntax highlighting to the specified XML code. |
|
123 | - * |
|
124 | - * @param string $xml The XML to highlight. |
|
125 | - * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
126 | - * @return string |
|
127 | - */ |
|
121 | + /** |
|
122 | + * Adds HTML syntax highlighting to the specified XML code. |
|
123 | + * |
|
124 | + * @param string $xml The XML to highlight. |
|
125 | + * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
126 | + * @return string |
|
127 | + */ |
|
128 | 128 | public static function xml(string $xml, bool $formatSource=false) : string |
129 | 129 | { |
130 | 130 | if($formatSource) |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | return self::parseString($xml, 'xml'); |
142 | 142 | } |
143 | 143 | |
144 | - /** |
|
145 | - * Adds HTML syntax highlighting to the specified HTML code. |
|
146 | - * |
|
147 | - * @param string $html |
|
148 | - * @param bool $formatSource |
|
149 | - * @return string |
|
150 | - */ |
|
144 | + /** |
|
145 | + * Adds HTML syntax highlighting to the specified HTML code. |
|
146 | + * |
|
147 | + * @param string $html |
|
148 | + * @param bool $formatSource |
|
149 | + * @return string |
|
150 | + */ |
|
151 | 151 | public static function html(string $html, bool $formatSource=false) : string |
152 | 152 | { |
153 | 153 | if($formatSource) |
@@ -164,27 +164,27 @@ discard block |
||
164 | 164 | return self::parseString($html, 'xml'); |
165 | 165 | } |
166 | 166 | |
167 | - /** |
|
168 | - * Adds HTML syntax highlighting to a bit of PHP code. |
|
169 | - * |
|
170 | - * @param string $phpCode |
|
171 | - * @return string |
|
172 | - */ |
|
167 | + /** |
|
168 | + * Adds HTML syntax highlighting to a bit of PHP code. |
|
169 | + * |
|
170 | + * @param string $phpCode |
|
171 | + * @return string |
|
172 | + */ |
|
173 | 173 | public static function php(string $phpCode) : string |
174 | 174 | { |
175 | 175 | return self::parseString($phpCode, 'php'); |
176 | 176 | } |
177 | 177 | |
178 | - /** |
|
179 | - * Adds HTML syntax highlighting to an URL. |
|
180 | - * |
|
181 | - * NOTE: Includes the necessary CSS styles. When |
|
182 | - * highlighting several URLs in the same page, |
|
183 | - * prefer using the `parseURL` function instead. |
|
184 | - * |
|
185 | - * @param string $url |
|
186 | - * @return string |
|
187 | - */ |
|
178 | + /** |
|
179 | + * Adds HTML syntax highlighting to an URL. |
|
180 | + * |
|
181 | + * NOTE: Includes the necessary CSS styles. When |
|
182 | + * highlighting several URLs in the same page, |
|
183 | + * prefer using the `parseURL` function instead. |
|
184 | + * |
|
185 | + * @param string $url |
|
186 | + * @return string |
|
187 | + */ |
|
188 | 188 | public static function url(string $url) : string |
189 | 189 | { |
190 | 190 | $info = parseURL($url); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function initUnits() : void |
50 | 50 | { |
51 | - if(isset(self::$units)) |
|
51 | + if (isset(self::$units)) |
|
52 | 52 | { |
53 | 53 | return; |
54 | 54 | } |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | public function toString() : string |
91 | 91 | { |
92 | 92 | // specifically handle zero |
93 | - if($this->seconds <= 0) |
|
93 | + if ($this->seconds <= 0) |
|
94 | 94 | { |
95 | - return '0 ' . t('seconds'); |
|
95 | + return '0 '.t('seconds'); |
|
96 | 96 | } |
97 | 97 | |
98 | - if($this->seconds < 1) |
|
98 | + if ($this->seconds < 1) |
|
99 | 99 | { |
100 | 100 | return t('less than a second'); |
101 | 101 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | |
105 | 105 | $last = array_pop($tokens); |
106 | 106 | |
107 | - if(empty($tokens)) |
|
107 | + if (empty($tokens)) |
|
108 | 108 | { |
109 | 109 | return $last; |
110 | 110 | } |
111 | 111 | |
112 | - return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
|
112 | + return implode(', ', $tokens).' '.t('and').' '.$last; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -122,18 +122,18 @@ discard block |
||
122 | 122 | $seconds = $this->seconds; |
123 | 123 | $tokens = array(); |
124 | 124 | |
125 | - foreach(self::$units as $def) |
|
125 | + foreach (self::$units as $def) |
|
126 | 126 | { |
127 | 127 | $unitValue = intval($seconds / $def['value']); |
128 | 128 | |
129 | - if($unitValue <= 0) |
|
129 | + if ($unitValue <= 0) |
|
130 | 130 | { |
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | |
134 | - $item = strval($unitValue) . ' '; |
|
134 | + $item = strval($unitValue).' '; |
|
135 | 135 | |
136 | - if(abs($unitValue) > 1) |
|
136 | + if (abs($unitValue) > 1) |
|
137 | 137 | { |
138 | 138 | $item .= $def['plural']; |
139 | 139 | } |
@@ -136,8 +136,7 @@ |
||
136 | 136 | if(abs($unitValue) > 1) |
137 | 137 | { |
138 | 138 | $item .= $def['plural']; |
139 | - } |
|
140 | - else |
|
139 | + } else |
|
141 | 140 | { |
142 | 141 | $item .= $def['singular']; |
143 | 142 | } |
@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class ConvertHelper_TimeConverter |
25 | 25 | { |
26 | - /** |
|
27 | - * @var float |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var float |
|
28 | + */ |
|
29 | 29 | private $seconds; |
30 | 30 | |
31 | - /** |
|
32 | - * @var array<int,array<string,string|int>>|NULL |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var array<int,array<string,string|int>>|NULL |
|
33 | + */ |
|
34 | 34 | private static $units; |
35 | 35 | |
36 | - /** |
|
37 | - * @param float $seconds |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @param float $seconds |
|
38 | + */ |
|
39 | 39 | public function __construct($seconds) |
40 | 40 | { |
41 | 41 | $this->seconds = $seconds; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | $this->initUnits(); |
44 | 44 | } |
45 | 45 | |
46 | - /** |
|
47 | - * Creates the list of units once per request as needed. |
|
48 | - */ |
|
46 | + /** |
|
47 | + * Creates the list of units once per request as needed. |
|
48 | + */ |
|
49 | 49 | private function initUnits() : void |
50 | 50 | { |
51 | 51 | if(isset(self::$units)) |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Resolves the list of converted units. |
|
117 | - * |
|
118 | - * @return string[] |
|
119 | - */ |
|
115 | + /** |
|
116 | + * Resolves the list of converted units. |
|
117 | + * |
|
118 | + * @return string[] |
|
119 | + */ |
|
120 | 120 | private function resolveTokens() : array |
121 | 121 | { |
122 | 122 | $seconds = $this->seconds; |
@@ -15,7 +15,7 @@ |
||
15 | 15 | $autoload = $root.'/vendor/autoload.php'; |
16 | 16 | |
17 | 17 | // we need the autoloader to be present |
18 | - if($autoload === false) |
|
18 | + if ($autoload === false) |
|
19 | 19 | { |
20 | 20 | die('<b>ERROR:</b> Autoloader not present. Run composer update first.'); |
21 | 21 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function detect(string $subjectString) : ?ConvertHelper_EOL |
123 | 123 | { |
124 | - if(empty($subjectString)) { |
|
124 | + if (empty($subjectString)) { |
|
125 | 125 | return null; |
126 | 126 | } |
127 | 127 | |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | $results = array(); |
130 | 130 | $chars = self::getEOLChars(); |
131 | 131 | |
132 | - foreach($chars as $def) |
|
132 | + foreach ($chars as $def) |
|
133 | 133 | { |
134 | 134 | $amount = substr_count($subjectString, $def['char']); |
135 | 135 | |
136 | - if($amount > $max) |
|
136 | + if ($amount > $max) |
|
137 | 137 | { |
138 | 138 | $max = $amount; |
139 | 139 | $results[] = $def; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - if(empty($results)) { |
|
143 | + if (empty($results)) { |
|
144 | 144 | return null; |
145 | 145 | } |
146 | 146 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public static function getEOLChars() : array |
158 | 158 | { |
159 | - if(isset(self::$eolChars)) { |
|
159 | + if (isset(self::$eolChars)) { |
|
160 | 160 | return self::$eolChars; |
161 | 161 | } |
162 | 162 |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | public const TYPE_LF = 'LF'; |
30 | 30 | public const TYPE_CR = 'CR'; |
31 | 31 | |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | 35 | protected $char; |
36 | 36 | |
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | 40 | protected $type; |
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $description; |
46 | 46 | |
47 | 47 | /** |
@@ -56,33 +56,33 @@ discard block |
||
56 | 56 | $this->description = $description; |
57 | 57 | } |
58 | 58 | |
59 | - /** |
|
60 | - * The actual EOL character. |
|
61 | - * @return string |
|
62 | - */ |
|
59 | + /** |
|
60 | + * The actual EOL character. |
|
61 | + * @return string |
|
62 | + */ |
|
63 | 63 | public function getCharacter() : string |
64 | 64 | { |
65 | 65 | return $this->char; |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * A more detailed, human readable description of the character. |
|
70 | - * @return string |
|
71 | - */ |
|
68 | + /** |
|
69 | + * A more detailed, human readable description of the character. |
|
70 | + * @return string |
|
71 | + */ |
|
72 | 72 | public function getDescription() : string |
73 | 73 | { |
74 | 74 | return $this->description; |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * The EOL character type, e.g. "CR+LF", "CR"... |
|
79 | - * @return string |
|
80 | - * |
|
81 | - * @see ConvertHelper_EOL::TYPE_CR |
|
82 | - * @see ConvertHelper_EOL::TYPE_CRLF |
|
83 | - * @see ConvertHelper_EOL::TYPE_LF |
|
84 | - * @see ConvertHelper_EOL::TYPE_LFCR |
|
85 | - */ |
|
77 | + /** |
|
78 | + * The EOL character type, e.g. "CR+LF", "CR"... |
|
79 | + * @return string |
|
80 | + * |
|
81 | + * @see ConvertHelper_EOL::TYPE_CR |
|
82 | + * @see ConvertHelper_EOL::TYPE_CRLF |
|
83 | + * @see ConvertHelper_EOL::TYPE_LF |
|
84 | + * @see ConvertHelper_EOL::TYPE_LFCR |
|
85 | + */ |
|
86 | 86 | public function getType() : string |
87 | 87 | { |
88 | 88 | return $this->type; |