@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | protected RequestHelper_Boundaries $boundaries; |
26 | 26 | protected string $transferEncoding = ''; |
27 | 27 | |
28 | - /** |
|
29 | - * @var array<string,string> |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var array<string,string> |
|
30 | + */ |
|
31 | 31 | protected array $dispositionParams = array(); |
32 | 32 | |
33 | 33 | public function __construct(RequestHelper_Boundaries $boundaries, string $content) |
@@ -41,46 +41,46 @@ discard block |
||
41 | 41 | return strlen($this->content); |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Sets the name of the request parameter. |
|
46 | - * |
|
47 | - * @param string $name |
|
48 | - * @return RequestHelper_Boundaries_Boundary |
|
49 | - */ |
|
44 | + /** |
|
45 | + * Sets the name of the request parameter. |
|
46 | + * |
|
47 | + * @param string $name |
|
48 | + * @return RequestHelper_Boundaries_Boundary |
|
49 | + */ |
|
50 | 50 | public function setName(string $name) : RequestHelper_Boundaries_Boundary |
51 | 51 | { |
52 | 52 | return $this->setDispositionParam('name', $name); |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Sets the filename to use for the content, if applicable. |
|
57 | - * |
|
58 | - * @param string $fileName |
|
59 | - * @return RequestHelper_Boundaries_Boundary |
|
60 | - */ |
|
55 | + /** |
|
56 | + * Sets the filename to use for the content, if applicable. |
|
57 | + * |
|
58 | + * @param string $fileName |
|
59 | + * @return RequestHelper_Boundaries_Boundary |
|
60 | + */ |
|
61 | 61 | public function setFileName(string $fileName) : RequestHelper_Boundaries_Boundary |
62 | 62 | { |
63 | 63 | return $this->setDispositionParam('filename', $fileName); |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Sets the content type to use for the content. |
|
68 | - * |
|
69 | - * @param string $contentType |
|
70 | - * @return RequestHelper_Boundaries_Boundary |
|
71 | - */ |
|
66 | + /** |
|
67 | + * Sets the content type to use for the content. |
|
68 | + * |
|
69 | + * @param string $contentType |
|
70 | + * @return RequestHelper_Boundaries_Boundary |
|
71 | + */ |
|
72 | 72 | public function setContentType(string $contentType) : RequestHelper_Boundaries_Boundary |
73 | 73 | { |
74 | 74 | $this->contentType = $contentType; |
75 | 75 | return $this; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Sets the encoding to specify for the content. |
|
80 | - * |
|
81 | - * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
82 | - * @return RequestHelper_Boundaries_Boundary |
|
83 | - */ |
|
78 | + /** |
|
79 | + * Sets the encoding to specify for the content. |
|
80 | + * |
|
81 | + * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
82 | + * @return RequestHelper_Boundaries_Boundary |
|
83 | + */ |
|
84 | 84 | public function setContentEncoding(string $encoding) : RequestHelper_Boundaries_Boundary |
85 | 85 | { |
86 | 86 | $this->contentEncoding = $encoding; |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | return $this; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Renders the mime boundary text. |
|
105 | - * |
|
106 | - * @return string |
|
107 | - */ |
|
103 | + /** |
|
104 | + * Renders the mime boundary text. |
|
105 | + * |
|
106 | + * @return string |
|
107 | + */ |
|
108 | 108 | public function render() : string |
109 | 109 | { |
110 | 110 | $eol = $this->boundaries->getEOL(); |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | $lines[] = '--'.$this->boundaries->getMimeBoundary(); |
114 | 114 | $lines[] = $this->renderContentDisposition(); |
115 | 115 | |
116 | - if(!empty($this->contentType)) |
|
116 | + if (!empty($this->contentType)) |
|
117 | 117 | { |
118 | 118 | $lines[] = $this->renderContentType(); |
119 | 119 | } |
120 | 120 | |
121 | - if(!empty($this->transferEncoding)) |
|
121 | + if (!empty($this->transferEncoding)) |
|
122 | 122 | { |
123 | 123 | $lines[] = $this->renderTransferEncoding(); |
124 | 124 | } |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | { |
134 | 134 | $result = 'Content-Disposition: form-data'; |
135 | 135 | |
136 | - foreach($this->dispositionParams as $name => $value) |
|
136 | + foreach ($this->dispositionParams as $name => $value) |
|
137 | 137 | { |
138 | - $result .= '; '.$name.'="' . $value . '"'; |
|
138 | + $result .= '; '.$name.'="'.$value.'"'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return $result; |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | |
144 | 144 | protected function renderContentType() : string |
145 | 145 | { |
146 | - $result = 'Content-Type: ' . $this->contentType; |
|
146 | + $result = 'Content-Type: '.$this->contentType; |
|
147 | 147 | |
148 | - if(!empty($this->contentEncoding)) |
|
148 | + if (!empty($this->contentEncoding)) |
|
149 | 149 | { |
150 | - $result .= '; charset="' . $this->contentEncoding.'"'; |
|
150 | + $result .= '; charset="'.$this->contentEncoding.'"'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return $result; |
@@ -155,6 +155,6 @@ discard block |
||
155 | 155 | |
156 | 156 | protected function renderTransferEncoding() : string |
157 | 157 | { |
158 | - return 'Content-Transfer-Encoding: ' . $this->transferEncoding; |
|
158 | + return 'Content-Transfer-Encoding: '.$this->transferEncoding; |
|
159 | 159 | } |
160 | 160 | } |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | { |
26 | 26 | public const SERIALIZE_SEPARATOR = '__SERIALIZE_SEP__'; |
27 | 27 | |
28 | - /** |
|
29 | - * @var XMLHelper_DOMErrors_Error[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var XMLHelper_DOMErrors_Error[] |
|
30 | + */ |
|
31 | 31 | private array $errors = array(); |
32 | 32 | |
33 | - /** |
|
34 | - * @param LibXMLError[]|XMLHelper_DOMErrors_Error[] $libxmlErrors |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @param LibXMLError[]|XMLHelper_DOMErrors_Error[] $libxmlErrors |
|
35 | + */ |
|
36 | 36 | public function __construct(array $libxmlErrors) |
37 | 37 | { |
38 | 38 | foreach($libxmlErrors as $error) |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | return $this->errors; |
62 | 62 | } |
63 | 63 | |
64 | - /** |
|
65 | - * Retrieves all warnings, if any. |
|
66 | - * |
|
67 | - * @return XMLHelper_DOMErrors_Error[] |
|
68 | - */ |
|
64 | + /** |
|
65 | + * Retrieves all warnings, if any. |
|
66 | + * |
|
67 | + * @return XMLHelper_DOMErrors_Error[] |
|
68 | + */ |
|
69 | 69 | public function getWarnings() : array |
70 | 70 | { |
71 | 71 | return $this->getByLevel(LIBXML_ERR_WARNING); |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * Retrieves all errors by the specified libxml error level. |
|
126 | - * |
|
127 | - * @param int $level |
|
128 | - * @return XMLHelper_DOMErrors_Error[] |
|
129 | - */ |
|
124 | + /** |
|
125 | + * Retrieves all errors by the specified libxml error level. |
|
126 | + * |
|
127 | + * @param int $level |
|
128 | + * @return XMLHelper_DOMErrors_Error[] |
|
129 | + */ |
|
130 | 130 | public function getByLevel(int $level) : array |
131 | 131 | { |
132 | 132 | $result = array(); |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | return $result; |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Retrieves all errors by the specified libxml error code. |
|
147 | - * |
|
148 | - * @param int $code |
|
149 | - * @return XMLHelper_DOMErrors_Error[] |
|
150 | - */ |
|
145 | + /** |
|
146 | + * Retrieves all errors by the specified libxml error code. |
|
147 | + * |
|
148 | + * @param int $code |
|
149 | + * @return XMLHelper_DOMErrors_Error[] |
|
150 | + */ |
|
151 | 151 | public function getByCode(int $code) : array |
152 | 152 | { |
153 | 153 | $result = array(); |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | return $result; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Checks whether there are errors matching the libxml error level. |
|
168 | - * |
|
169 | - * @param int $level |
|
170 | - * @return bool |
|
171 | - */ |
|
166 | + /** |
|
167 | + * Checks whether there are errors matching the libxml error level. |
|
168 | + * |
|
169 | + * @param int $level |
|
170 | + * @return bool |
|
171 | + */ |
|
172 | 172 | public function hasErrorsByLevel(int $level) : bool |
173 | 173 | { |
174 | 174 | foreach($this->errors as $error) |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | |
185 | - /** |
|
186 | - * Checks whether there are any errors matching the libxml error code. |
|
187 | - * |
|
188 | - * @param int $code |
|
189 | - * @return bool |
|
190 | - */ |
|
185 | + /** |
|
186 | + * Checks whether there are any errors matching the libxml error code. |
|
187 | + * |
|
188 | + * @param int $code |
|
189 | + * @return bool |
|
190 | + */ |
|
191 | 191 | public function hasErrorsByCode(int $code) : bool |
192 | 192 | { |
193 | 193 | foreach($this->errors as $error) |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | return $result; |
217 | 217 | } |
218 | 218 | |
219 | - /** |
|
220 | - * Serializes the error collection, so it can be stored and |
|
221 | - * restored as needed, using the `fromSerialized()` method. |
|
222 | - * |
|
223 | - * @return string |
|
224 | - * @see XMLHelper_DOMErrors::fromSerialized() |
|
225 | - */ |
|
219 | + /** |
|
220 | + * Serializes the error collection, so it can be stored and |
|
221 | + * restored as needed, using the `fromSerialized()` method. |
|
222 | + * |
|
223 | + * @return string |
|
224 | + * @see XMLHelper_DOMErrors::fromSerialized() |
|
225 | + */ |
|
226 | 226 | public function serialize() : string |
227 | 227 | { |
228 | 228 | $data = array(); |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function __construct(array $libxmlErrors) |
37 | 37 | { |
38 | - foreach($libxmlErrors as $error) |
|
38 | + foreach ($libxmlErrors as $error) |
|
39 | 39 | { |
40 | - if($error instanceof XMLHelper_DOMErrors_Error) |
|
40 | + if ($error instanceof XMLHelper_DOMErrors_Error) |
|
41 | 41 | { |
42 | 42 | $this->errors[] = $error; |
43 | 43 | } |
44 | - else if($error instanceof LibXMLError) |
|
44 | + else if ($error instanceof LibXMLError) |
|
45 | 45 | { |
46 | 46 | $this->errors[] = new XMLHelper_DOMErrors_Error($error); |
47 | 47 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | { |
132 | 132 | $result = array(); |
133 | 133 | |
134 | - foreach($this->errors as $error) |
|
134 | + foreach ($this->errors as $error) |
|
135 | 135 | { |
136 | - if($error->isLevel($level)) |
|
136 | + if ($error->isLevel($level)) |
|
137 | 137 | { |
138 | 138 | $result[] = $error; |
139 | 139 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | { |
153 | 153 | $result = array(); |
154 | 154 | |
155 | - foreach($this->errors as $error) |
|
155 | + foreach ($this->errors as $error) |
|
156 | 156 | { |
157 | - if($error->isCode($code)) |
|
157 | + if ($error->isCode($code)) |
|
158 | 158 | { |
159 | 159 | $result[] = $error; |
160 | 160 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function hasErrorsByLevel(int $level) : bool |
173 | 173 | { |
174 | - foreach($this->errors as $error) |
|
174 | + foreach ($this->errors as $error) |
|
175 | 175 | { |
176 | - if($error->isLevel($level)) |
|
176 | + if ($error->isLevel($level)) |
|
177 | 177 | { |
178 | 178 | return true; |
179 | 179 | } |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function hasErrorsByCode(int $code) : bool |
192 | 192 | { |
193 | - foreach($this->errors as $error) |
|
193 | + foreach ($this->errors as $error) |
|
194 | 194 | { |
195 | - if($error->isCode($code)) |
|
195 | + if ($error->isCode($code)) |
|
196 | 196 | { |
197 | 197 | return true; |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | $result = array(); |
210 | 210 | |
211 | - foreach($this->errors as $error) |
|
211 | + foreach ($this->errors as $error) |
|
212 | 212 | { |
213 | 213 | $result[] = $error->toArray(); |
214 | 214 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | $data = array(); |
229 | 229 | |
230 | - foreach($this->errors as $error) |
|
230 | + foreach ($this->errors as $error) |
|
231 | 231 | { |
232 | 232 | $data[] = $error->serialize(); |
233 | 233 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $parts = explode(self::SERIALIZE_SEPARATOR, $serialized); |
250 | 250 | $list = array(); |
251 | 251 | |
252 | - foreach($parts as $part) |
|
252 | + foreach ($parts as $part) |
|
253 | 253 | { |
254 | 254 | $list[] = XMLHelper_DOMErrors_Error::fromSerialized($part); |
255 | 255 | } |
@@ -40,8 +40,7 @@ |
||
40 | 40 | if($error instanceof XMLHelper_DOMErrors_Error) |
41 | 41 | { |
42 | 42 | $this->errors[] = $error; |
43 | - } |
|
44 | - else if($error instanceof LibXMLError) |
|
43 | + } else if($error instanceof LibXMLError) |
|
45 | 44 | { |
46 | 45 | $this->errors[] = new XMLHelper_DOMErrors_Error($error); |
47 | 46 | } |
@@ -27,9 +27,9 @@ |
||
27 | 27 | public const ERROR_CANNOT_UNSERIALIZE_ERROR_DATA = 57201; |
28 | 28 | public const ERROR_ERROR_DATA_KEY_MISSING = 57202; |
29 | 29 | |
30 | - /** |
|
31 | - * @var LibXMLError |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var LibXMLError |
|
32 | + */ |
|
33 | 33 | private LibXMLError $error; |
34 | 34 | |
35 | 35 | /** |
@@ -90,9 +90,9 @@ |
||
90 | 90 | */ |
91 | 91 | private static function checkErrorData(array $data) : void |
92 | 92 | { |
93 | - foreach(self::$requiredKeys as $key) |
|
93 | + foreach (self::$requiredKeys as $key) |
|
94 | 94 | { |
95 | - if(!array_key_exists($key, $data)) |
|
95 | + if (!array_key_exists($key, $data)) |
|
96 | 96 | { |
97 | 97 | throw new XMLHelper_Exception( |
98 | 98 | 'Required key missing in error data', |
@@ -58,8 +58,7 @@ |
||
58 | 58 | try |
59 | 59 | { |
60 | 60 | $data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR); |
61 | - } |
|
62 | - catch (JsonException $e) |
|
61 | + } catch (JsonException $e) |
|
63 | 62 | { |
64 | 63 | throw new XMLHelper_Exception( |
65 | 64 | 'Could not unserialize error data', |
@@ -28,32 +28,32 @@ |
||
28 | 28 | |
29 | 29 | private ?SimpleXMLElement $element = null; |
30 | 30 | |
31 | - /** |
|
32 | - * @var XMLHelper_SimpleXML_Error[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var XMLHelper_SimpleXML_Error[] |
|
33 | + */ |
|
34 | 34 | private array $errors = array(); |
35 | 35 | |
36 | - /** |
|
37 | - * Creates a simplexml instance from an XML string. |
|
38 | - * |
|
39 | - * NOTE: returns false in case of a fatal error. |
|
40 | - * |
|
41 | - * @param string $string |
|
42 | - * @return SimpleXMLElement|NULL |
|
43 | - */ |
|
36 | + /** |
|
37 | + * Creates a simplexml instance from an XML string. |
|
38 | + * |
|
39 | + * NOTE: returns false in case of a fatal error. |
|
40 | + * |
|
41 | + * @param string $string |
|
42 | + * @return SimpleXMLElement|NULL |
|
43 | + */ |
|
44 | 44 | public function loadString(string $string) : ?SimpleXMLElement |
45 | 45 | { |
46 | 46 | return $this->load('string', $string); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Creates a simplexml instance from an XML file. |
|
51 | - * |
|
52 | - * NOTE: returns false in case of a fatal error. |
|
53 | - * |
|
54 | - * @param string $file |
|
55 | - * @return SimpleXMLElement|NULL |
|
56 | - */ |
|
49 | + /** |
|
50 | + * Creates a simplexml instance from an XML file. |
|
51 | + * |
|
52 | + * NOTE: returns false in case of a fatal error. |
|
53 | + * |
|
54 | + * @param string $file |
|
55 | + * @return SimpleXMLElement|NULL |
|
56 | + */ |
|
57 | 57 | public function loadFile(string $file) : ?SimpleXMLElement |
58 | 58 | { |
59 | 59 | return $this->load('file', $file); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // error wrappers. |
84 | 84 | $errors = libxml_get_errors(); |
85 | 85 | |
86 | - foreach($errors as $error) |
|
86 | + foreach ($errors as $error) |
|
87 | 87 | { |
88 | 88 | $this->errors[] = new XMLHelper_SimpleXML_Error($this, $error); |
89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $xml = $function($subject); |
99 | 99 | |
100 | - if($xml instanceof SimpleXMLElement) |
|
100 | + if ($xml instanceof SimpleXMLElement) |
|
101 | 101 | { |
102 | 102 | return $xml; |
103 | 103 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function getConverter() : XMLHelper_Converter |
109 | 109 | { |
110 | - if($this->element instanceof SimpleXMLElement) |
|
110 | + if ($this->element instanceof SimpleXMLElement) |
|
111 | 111 | { |
112 | 112 | return XMLHelper::convertElement($this->element); |
113 | 113 | } |
@@ -10,9 +10,9 @@ |
||
10 | 10 | { |
11 | 11 | protected XMLHelper_SimpleXML $xml; |
12 | 12 | |
13 | - /** |
|
14 | - * @var LibXMLError |
|
15 | - */ |
|
13 | + /** |
|
14 | + * @var LibXMLError |
|
15 | + */ |
|
16 | 16 | protected LibXMLError $nativeError; |
17 | 17 | |
18 | 18 | public function __construct(XMLHelper_SimpleXML $xml, LibXMLError $nativeError) |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | class Request_RefreshParams_Exclude_Callback extends Request_RefreshParams_Exclude |
22 | 22 | { |
23 | - /** |
|
24 | - * @var callable |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var callable |
|
25 | + */ |
|
26 | 26 | private $callback; |
27 | 27 | |
28 | 28 | public function __construct(callable $callback) |
@@ -6,9 +6,9 @@ discard block |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed|NULL |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed|NULL |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | 14 | protected VariableInfo $info; |
@@ -24,11 +24,11 @@ discard block |
||
24 | 24 | |
25 | 25 | abstract protected function init() : void; |
26 | 26 | |
27 | - /** |
|
28 | - * Renders the value to the target format. |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
27 | + /** |
|
28 | + * Renders the value to the target format. |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | 32 | public function render() : string |
33 | 33 | { |
34 | 34 | return $this->_render(); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | return $this->setOption('separatorChar', $char); |
47 | 47 | } |
48 | 48 | |
49 | - public function setTrailingNewline(bool $useNewline=true) : self |
|
49 | + public function setTrailingNewline(bool $useNewline = true) : self |
|
50 | 50 | { |
51 | 51 | return $this->setOption('trailingNewline', $useNewline); |
52 | 52 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $args = $args[0]; |
65 | 65 | } |
66 | 66 | |
67 | - $this->lines[] = '"' . implode('"'.$this->getOption('separatorChar').'"', $args) . '"'; |
|
67 | + $this->lines[] = '"'.implode('"'.$this->getOption('separatorChar').'"', $args).'"'; |
|
68 | 68 | |
69 | 69 | return $this; |
70 | 70 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | $csv = implode(PHP_EOL, $this->lines); |
82 | 82 | |
83 | - if($this->getOption('trailingNewline')) { |
|
83 | + if ($this->getOption('trailingNewline')) { |
|
84 | 84 | $csv .= PHP_EOL; |
85 | 85 | } |
86 | 86 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function setOption(string $name, $value) : self |
96 | 96 | { |
97 | - if(!isset($this->options)) { |
|
97 | + if (!isset($this->options)) { |
|
98 | 98 | $this->options = $this->getDefaultOptions(); |
99 | 99 | } |
100 | 100 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function setOptions(array $options) : self |
110 | 110 | { |
111 | - foreach($options as $name => $value) { |
|
111 | + foreach ($options as $name => $value) { |
|
112 | 112 | $this->setOption($name, $value); |
113 | 113 | } |
114 | 114 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * @param mixed|NULL $default |
121 | 121 | * @return mixed|NULL |
122 | 122 | */ |
123 | - public function getOption(string $name, $default=null) |
|
123 | + public function getOption(string $name, $default = null) |
|
124 | 124 | { |
125 | - if(!isset($this->options)) { |
|
125 | + if (!isset($this->options)) { |
|
126 | 126 | $this->options = $this->getDefaultOptions(); |
127 | 127 | } |
128 | 128 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | public function hasOption(string $name) : bool |
133 | 133 | { |
134 | - if(!isset($this->options)) { |
|
134 | + if (!isset($this->options)) { |
|
135 | 135 | $this->options = $this->getDefaultOptions(); |
136 | 136 | } |
137 | 137 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function getOptions() : array |
145 | 145 | { |
146 | - if(!isset($this->options)) { |
|
146 | + if (!isset($this->options)) { |
|
147 | 147 | $this->options = $this->getDefaultOptions(); |
148 | 148 | } |
149 | 149 |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Creates and returns a new instance of the CSV builder which |
|
83 | - * can be used to build CSV from scratch. |
|
84 | - * |
|
85 | - * @return CSVHelper_Builder |
|
86 | - */ |
|
81 | + /** |
|
82 | + * Creates and returns a new instance of the CSV builder which |
|
83 | + * can be used to build CSV from scratch. |
|
84 | + * |
|
85 | + * @return CSVHelper_Builder |
|
86 | + */ |
|
87 | 87 | public static function createBuilder() : CSVHelper_Builder |
88 | 88 | { |
89 | 89 | return new CSVHelper_Builder(); |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | |
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Loads CSV data from a string. |
|
96 | - * |
|
97 | - * Note: Use the {@link hasErrors()} method to |
|
98 | - * check if the string could be parsed correctly |
|
99 | - * afterwards. |
|
100 | - * |
|
101 | - * @param string $string |
|
102 | - * @return $this |
|
103 | - */ |
|
94 | + /** |
|
95 | + * Loads CSV data from a string. |
|
96 | + * |
|
97 | + * Note: Use the {@link hasErrors()} method to |
|
98 | + * check if the string could be parsed correctly |
|
99 | + * afterwards. |
|
100 | + * |
|
101 | + * @param string $string |
|
102 | + * @return $this |
|
103 | + */ |
|
104 | 104 | public function loadString(string $string) : self |
105 | 105 | { |
106 | 106 | // remove any UTF byte order marks that may still be present in the string |
@@ -114,20 +114,20 @@ discard block |
||
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Loads CSV data from a file. |
|
119 | - * |
|
120 | - * Note: Use the {@link hasErrors()} method to |
|
121 | - * check if the string could be parsed correctly |
|
122 | - * afterwards. |
|
123 | - * |
|
124 | - * @param string $file |
|
125 | - * @throws FileHelper_Exception |
|
126 | - * @return CSVHelper |
|
127 | - * |
|
128 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
129 | - * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
130 | - */ |
|
117 | + /** |
|
118 | + * Loads CSV data from a file. |
|
119 | + * |
|
120 | + * Note: Use the {@link hasErrors()} method to |
|
121 | + * check if the string could be parsed correctly |
|
122 | + * afterwards. |
|
123 | + * |
|
124 | + * @param string $file |
|
125 | + * @throws FileHelper_Exception |
|
126 | + * @return CSVHelper |
|
127 | + * |
|
128 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
129 | + * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
130 | + */ |
|
131 | 131 | public function loadFile(string $file) : self |
132 | 132 | { |
133 | 133 | $csv = FileHelper::readContents($file); |
@@ -188,19 +188,19 @@ discard block |
||
188 | 188 | return $this->headersPosition === $position; |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Specifies where the headers are positioned in the |
|
193 | - * CSV, or turns them off entirely. Use the class constants |
|
194 | - * to ensure the value is correct. |
|
195 | - * |
|
196 | - * @param string $position |
|
197 | - * @throws CSVHelper_Exception |
|
198 | - * @return $this |
|
199 | - * |
|
200 | - * @see CSVHelper::HEADERS_LEFT |
|
201 | - * @see CSVHelper::HEADERS_TOP |
|
202 | - * @see CSVHelper::HEADERS_NONE |
|
203 | - */ |
|
191 | + /** |
|
192 | + * Specifies where the headers are positioned in the |
|
193 | + * CSV, or turns them off entirely. Use the class constants |
|
194 | + * to ensure the value is correct. |
|
195 | + * |
|
196 | + * @param string $position |
|
197 | + * @throws CSVHelper_Exception |
|
198 | + * @return $this |
|
199 | + * |
|
200 | + * @see CSVHelper::HEADERS_LEFT |
|
201 | + * @see CSVHelper::HEADERS_TOP |
|
202 | + * @see CSVHelper::HEADERS_NONE |
|
203 | + */ |
|
204 | 204 | public function setHeadersPosition(string $position) : self |
205 | 205 | { |
206 | 206 | $validPositions = array( |
@@ -227,13 +227,13 @@ discard block |
||
227 | 227 | return $this; |
228 | 228 | } |
229 | 229 | |
230 | - /** |
|
231 | - * Resets all internal data, allowing to start entirely anew |
|
232 | - * with a new file, or to start building a new CSV file from |
|
233 | - * scratch. |
|
234 | - * |
|
235 | - * @return $this |
|
236 | - */ |
|
230 | + /** |
|
231 | + * Resets all internal data, allowing to start entirely anew |
|
232 | + * with a new file, or to start building a new CSV file from |
|
233 | + * scratch. |
|
234 | + * |
|
235 | + * @return $this |
|
236 | + */ |
|
237 | 237 | public function reset() : self |
238 | 238 | { |
239 | 239 | $this->data = array(); |
@@ -253,81 +253,81 @@ discard block |
||
253 | 253 | return $this->data; |
254 | 254 | } |
255 | 255 | |
256 | - /** |
|
257 | - * Retrieves the row at the specified index. |
|
258 | - * If there is no data at the index, this will |
|
259 | - * return an array populated with empty strings |
|
260 | - * for all available columns. |
|
261 | - * |
|
262 | - * Tip: Use the {@link rowExists()} method to check |
|
263 | - * whether the specified row exists. |
|
264 | - * |
|
265 | - * @param integer $index |
|
266 | - * @return array<int,mixed> |
|
267 | - * @see rowExists() |
|
268 | - */ |
|
256 | + /** |
|
257 | + * Retrieves the row at the specified index. |
|
258 | + * If there is no data at the index, this will |
|
259 | + * return an array populated with empty strings |
|
260 | + * for all available columns. |
|
261 | + * |
|
262 | + * Tip: Use the {@link rowExists()} method to check |
|
263 | + * whether the specified row exists. |
|
264 | + * |
|
265 | + * @param integer $index |
|
266 | + * @return array<int,mixed> |
|
267 | + * @see rowExists() |
|
268 | + */ |
|
269 | 269 | public function getRow(int $index) : array |
270 | 270 | { |
271 | 271 | return $this->data[$index] ?? array_fill(0, $this->rowCount, ''); |
272 | 272 | } |
273 | 273 | |
274 | - /** |
|
275 | - * Checks whether the specified row exists in the data set. |
|
276 | - * @param integer $index |
|
277 | - * @return boolean |
|
278 | - */ |
|
274 | + /** |
|
275 | + * Checks whether the specified row exists in the data set. |
|
276 | + * @param integer $index |
|
277 | + * @return boolean |
|
278 | + */ |
|
279 | 279 | public function rowExists(int $index) : bool |
280 | 280 | { |
281 | 281 | return isset($this->data[$index]); |
282 | 282 | } |
283 | 283 | |
284 | - /** |
|
285 | - * Counts the amount of rows in the parsed CSV, |
|
286 | - * excluding the headers if any, depending on |
|
287 | - * their position. |
|
288 | - * |
|
289 | - * @return integer |
|
290 | - */ |
|
284 | + /** |
|
285 | + * Counts the amount of rows in the parsed CSV, |
|
286 | + * excluding the headers if any, depending on |
|
287 | + * their position. |
|
288 | + * |
|
289 | + * @return integer |
|
290 | + */ |
|
291 | 291 | public function countRows() : int |
292 | 292 | { |
293 | 293 | return $this->rowCount; |
294 | 294 | } |
295 | 295 | |
296 | - /** |
|
297 | - * Counts the amount of rows in the parsed CSV, |
|
298 | - * excluding the headers if any, depending on |
|
299 | - * their position. |
|
300 | - * |
|
301 | - * @return integer |
|
302 | - */ |
|
296 | + /** |
|
297 | + * Counts the amount of rows in the parsed CSV, |
|
298 | + * excluding the headers if any, depending on |
|
299 | + * their position. |
|
300 | + * |
|
301 | + * @return integer |
|
302 | + */ |
|
303 | 303 | public function countColumns() : int |
304 | 304 | { |
305 | 305 | return $this->columnCount; |
306 | 306 | } |
307 | 307 | |
308 | - /** |
|
309 | - * Retrieves the headers, if any. Specify the position of the |
|
310 | - * headers first to ensure this works correctly. |
|
311 | - * |
|
312 | - * @return string[] Indexed array with header names. |
|
313 | - */ |
|
308 | + /** |
|
309 | + * Retrieves the headers, if any. Specify the position of the |
|
310 | + * headers first to ensure this works correctly. |
|
311 | + * |
|
312 | + * @return string[] Indexed array with header names. |
|
313 | + */ |
|
314 | 314 | public function getHeaders() : array |
315 | 315 | { |
316 | 316 | return $this->headers; |
317 | 317 | } |
318 | 318 | |
319 | - /** |
|
320 | - * Retrieves the column at the specified index. If there |
|
321 | - * is no column at the index, this returns an array |
|
322 | - * populated with empty strings. |
|
323 | - * |
|
324 | - * Tip: Use the {@link columnExists()} method to check |
|
325 | - * whether a column exists. |
|
326 | - * |
|
327 | - * @param integer $index |
|
328 | - * @return string[] |
|
329 | - * @see columnExists() |
|
330 | - */ |
|
319 | + /** |
|
320 | + * Retrieves the column at the specified index. If there |
|
321 | + * is no column at the index, this returns an array |
|
322 | + * populated with empty strings. |
|
323 | + * |
|
324 | + * Tip: Use the {@link columnExists()} method to check |
|
325 | + * whether a column exists. |
|
326 | + * |
|
327 | + * @param integer $index |
|
328 | + * @return string[] |
|
329 | + * @see columnExists() |
|
330 | + */ |
|
331 | 331 | public function getColumn(int $index) : array |
332 | 332 | { |
333 | 333 | $data = array(); |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | return $data; |
343 | 343 | } |
344 | 344 | |
345 | - /** |
|
346 | - * Checks whether the specified column exists in the data set. |
|
347 | - * @param integer $index |
|
348 | - * @return boolean |
|
349 | - */ |
|
345 | + /** |
|
346 | + * Checks whether the specified column exists in the data set. |
|
347 | + * @param integer $index |
|
348 | + * @return boolean |
|
349 | + */ |
|
350 | 350 | public function columnExists(int $index) : bool |
351 | 351 | { |
352 | 352 | return $index < $this->columnCount; |
@@ -406,22 +406,22 @@ discard block |
||
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | - /** |
|
410 | - * Checks whether any errors have been encountered |
|
411 | - * while parsing the CSV. |
|
412 | - * |
|
413 | - * @return boolean |
|
414 | - * @see getErrorMessages() |
|
415 | - */ |
|
409 | + /** |
|
410 | + * Checks whether any errors have been encountered |
|
411 | + * while parsing the CSV. |
|
412 | + * |
|
413 | + * @return boolean |
|
414 | + * @see getErrorMessages() |
|
415 | + */ |
|
416 | 416 | public function hasErrors() : bool |
417 | 417 | { |
418 | 418 | return !empty($this->errors); |
419 | 419 | } |
420 | 420 | |
421 | - /** |
|
422 | - * Retrieves all error messages. |
|
423 | - * @return string[] |
|
424 | - */ |
|
421 | + /** |
|
422 | + * Retrieves all error messages. |
|
423 | + * @return string[] |
|
424 | + */ |
|
425 | 425 | public function getErrorMessages() : array |
426 | 426 | { |
427 | 427 | return $this->errors; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | self::HEADERS_TOP |
210 | 210 | ); |
211 | 211 | |
212 | - if(!in_array($position, $validPositions)) { |
|
212 | + if (!in_array($position, $validPositions)) { |
|
213 | 213 | throw new CSVHelper_Exception( |
214 | 214 | 'Invalid headers position', |
215 | 215 | sprintf( |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | { |
333 | 333 | $data = array(); |
334 | 334 | |
335 | - for($i=0; $i < $this->rowCount; $i++) |
|
335 | + for ($i = 0; $i < $this->rowCount; $i++) |
|
336 | 336 | { |
337 | 337 | $value = $this->data[$i][$index] ?? ''; |
338 | 338 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | { |
357 | 357 | $this->reset(); |
358 | 358 | |
359 | - if(empty(trim($this->csv))) { |
|
359 | + if (empty(trim($this->csv))) { |
|
360 | 360 | $this->addError('Tried to parse an empty CSV string.'); |
361 | 361 | return; |
362 | 362 | } |
@@ -368,14 +368,14 @@ discard block |
||
368 | 368 | |
369 | 369 | $parser = self::createParser(); |
370 | 370 | |
371 | - if(!$parser->parse($this->csv)) { |
|
371 | + if (!$parser->parse($this->csv)) { |
|
372 | 372 | $this->addError('The CSV string could not be parsed.'); |
373 | 373 | return; |
374 | 374 | } |
375 | 375 | |
376 | 376 | $result = $parser->data; |
377 | 377 | |
378 | - switch($this->headersPosition) |
|
378 | + switch ($this->headersPosition) |
|
379 | 379 | { |
380 | 380 | case self::HEADERS_TOP: |
381 | 381 | $this->headers = array_shift($result); |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | $this->data = $result; |
399 | 399 | $this->rowCount = count($this->data); |
400 | 400 | |
401 | - for($i=0; $i < $this->rowCount; $i++) { |
|
401 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
402 | 402 | $amount = count($this->data[$i]); |
403 | - if($amount > $this->columnCount) { |
|
403 | + if ($amount > $this->columnCount) { |
|
404 | 404 | $this->columnCount = $amount; |
405 | 405 | } |
406 | 406 | } |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | ',,' => ',' |
444 | 444 | ); |
445 | 445 | |
446 | - foreach($search as $char => $separator) { |
|
447 | - if(strpos($this->csv, $char) !== false) { |
|
446 | + foreach ($search as $char => $separator) { |
|
447 | + if (strpos($this->csv, $char) !== false) { |
|
448 | 448 | return $separator; |
449 | 449 | } |
450 | 450 | } |
@@ -458,11 +458,11 @@ discard block |
||
458 | 458 | * @param string $delimiter |
459 | 459 | * @return Csv |
460 | 460 | */ |
461 | - public static function createParser(string $delimiter=self::DELIMITER_AUTO) : Csv |
|
461 | + public static function createParser(string $delimiter = self::DELIMITER_AUTO) : Csv |
|
462 | 462 | { |
463 | 463 | $csv = new Csv(); |
464 | 464 | |
465 | - if($delimiter !== self::DELIMITER_AUTO) { |
|
465 | + if ($delimiter !== self::DELIMITER_AUTO) { |
|
466 | 466 | $csv->delimiter = $delimiter; |
467 | 467 | } |
468 | 468 | |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | $result = $parser->auto($path); |
495 | 495 | |
496 | - if(is_string($result)) { |
|
496 | + if (is_string($result)) { |
|
497 | 497 | return $parser->data; |
498 | 498 | } |
499 | 499 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | $parser = self::createParser(); |
527 | 527 | $result = $parser->parse($string); |
528 | 528 | |
529 | - if($result === true) { |
|
529 | + if ($result === true) { |
|
530 | 530 | return $parser->data; |
531 | 531 | } |
532 | 532 |