@@ -43,60 +43,60 @@ discard block |
||
43 | 43 | */ |
44 | 44 | class Highlighter |
45 | 45 | { |
46 | - /** |
|
47 | - * Creates a new GeSHi instance from a source code string. |
|
48 | - * |
|
49 | - * @param string $sourceCode |
|
50 | - * @param string $format |
|
51 | - * @return GeSHi |
|
52 | - */ |
|
46 | + /** |
|
47 | + * Creates a new GeSHi instance from a source code string. |
|
48 | + * |
|
49 | + * @param string $sourceCode |
|
50 | + * @param string $format |
|
51 | + * @return GeSHi |
|
52 | + */ |
|
53 | 53 | public static function fromString(string $sourceCode, string $format) : GeSHi |
54 | 54 | { |
55 | 55 | return new GeSHi($sourceCode, $format); |
56 | 56 | } |
57 | 57 | |
58 | - /** |
|
59 | - * Creates a new GeSHi instance from the contents of a file. |
|
60 | - * |
|
61 | - * @param string $path |
|
62 | - * @param string $format |
|
63 | - * @return GeSHi |
|
64 | - */ |
|
58 | + /** |
|
59 | + * Creates a new GeSHi instance from the contents of a file. |
|
60 | + * |
|
61 | + * @param string $path |
|
62 | + * @param string $format |
|
63 | + * @return GeSHi |
|
64 | + */ |
|
65 | 65 | public static function fromFile(string $path, string $format) : GeSHi |
66 | 66 | { |
67 | 67 | return self::fromString(FileHelper::readContents($path), $format); |
68 | 68 | } |
69 | 69 | |
70 | - /** |
|
71 | - * Parses and highlights the target string. |
|
72 | - * |
|
73 | - * @param string $sourceCode |
|
74 | - * @param string $format |
|
75 | - * @return string |
|
76 | - */ |
|
70 | + /** |
|
71 | + * Parses and highlights the target string. |
|
72 | + * |
|
73 | + * @param string $sourceCode |
|
74 | + * @param string $format |
|
75 | + * @return string |
|
76 | + */ |
|
77 | 77 | public static function parseString(string $sourceCode, string $format) : string |
78 | 78 | { |
79 | 79 | return self::fromString($sourceCode, $format)->parse_code(); |
80 | 80 | } |
81 | 81 | |
82 | - /** |
|
83 | - * Parses and highlights the contents of the target file. |
|
84 | - * |
|
85 | - * @param string $path |
|
86 | - * @param string $format |
|
87 | - * @return string |
|
88 | - */ |
|
82 | + /** |
|
83 | + * Parses and highlights the contents of the target file. |
|
84 | + * |
|
85 | + * @param string $path |
|
86 | + * @param string $format |
|
87 | + * @return string |
|
88 | + */ |
|
89 | 89 | public static function parseFile(string $path, string $format) : string |
90 | 90 | { |
91 | 91 | return self::fromFile($path, $format)->parse_code(); |
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * Adds HTML syntax highlighting to the specified SQL string. |
|
96 | - * |
|
97 | - * @param string $sql |
|
98 | - * @return string |
|
99 | - */ |
|
94 | + /** |
|
95 | + * Adds HTML syntax highlighting to the specified SQL string. |
|
96 | + * |
|
97 | + * @param string $sql |
|
98 | + * @return string |
|
99 | + */ |
|
100 | 100 | public static function sql(string $sql) : string |
101 | 101 | { |
102 | 102 | return self::parseString($sql, 'sql'); |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | return self::parseString($subject, 'javascript'); |
123 | 123 | } |
124 | 124 | |
125 | - /** |
|
126 | - * Adds HTML syntax highlighting to the specified XML code. |
|
127 | - * |
|
128 | - * @param string $xml The XML to highlight. |
|
129 | - * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
130 | - * @return string |
|
131 | - */ |
|
125 | + /** |
|
126 | + * Adds HTML syntax highlighting to the specified XML code. |
|
127 | + * |
|
128 | + * @param string $xml The XML to highlight. |
|
129 | + * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
130 | + * @return string |
|
131 | + */ |
|
132 | 132 | public static function xml(string $xml, bool $formatSource=false) : string |
133 | 133 | { |
134 | 134 | if($formatSource) |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | return self::parseString($xml, 'xml'); |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * Adds HTML syntax highlighting to the specified HTML code. |
|
150 | - * |
|
151 | - * @param string $html |
|
152 | - * @param bool $formatSource |
|
153 | - * @return string |
|
154 | - */ |
|
148 | + /** |
|
149 | + * Adds HTML syntax highlighting to the specified HTML code. |
|
150 | + * |
|
151 | + * @param string $html |
|
152 | + * @param bool $formatSource |
|
153 | + * @return string |
|
154 | + */ |
|
155 | 155 | public static function html(string $html, bool $formatSource=false) : string |
156 | 156 | { |
157 | 157 | if($formatSource) |
@@ -168,27 +168,27 @@ discard block |
||
168 | 168 | return self::parseString($html, 'xml'); |
169 | 169 | } |
170 | 170 | |
171 | - /** |
|
172 | - * Adds HTML syntax highlighting to a bit of PHP code. |
|
173 | - * |
|
174 | - * @param string $phpCode |
|
175 | - * @return string |
|
176 | - */ |
|
171 | + /** |
|
172 | + * Adds HTML syntax highlighting to a bit of PHP code. |
|
173 | + * |
|
174 | + * @param string $phpCode |
|
175 | + * @return string |
|
176 | + */ |
|
177 | 177 | public static function php(string $phpCode) : string |
178 | 178 | { |
179 | 179 | return self::parseString($phpCode, 'php'); |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Adds HTML syntax highlighting to an URL. |
|
184 | - * |
|
185 | - * NOTE: Includes the necessary CSS styles. When |
|
186 | - * highlighting several URLs in the same page, |
|
187 | - * prefer using the `parseURL` function instead. |
|
188 | - * |
|
189 | - * @param string $url |
|
190 | - * @return string |
|
191 | - */ |
|
182 | + /** |
|
183 | + * Adds HTML syntax highlighting to an URL. |
|
184 | + * |
|
185 | + * NOTE: Includes the necessary CSS styles. When |
|
186 | + * highlighting several URLs in the same page, |
|
187 | + * prefer using the `parseURL` function instead. |
|
188 | + * |
|
189 | + * @param string $url |
|
190 | + * @return string |
|
191 | + */ |
|
192 | 192 | public static function url(string $url) : string |
193 | 193 | { |
194 | 194 | $info = parseURL($url); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function json($subject) : string |
114 | 114 | { |
115 | - if(!is_string($subject)) |
|
115 | + if (!is_string($subject)) |
|
116 | 116 | { |
117 | 117 | $subject = JSONConverter::var2json($subject, JSON_PRETTY_PRINT); |
118 | 118 | } |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | * @param bool $formatSource Whether to format the source with indentation to make it readable. |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - public static function xml(string $xml, bool $formatSource=false) : string |
|
132 | + public static function xml(string $xml, bool $formatSource = false) : string |
|
133 | 133 | { |
134 | - if($formatSource) |
|
134 | + if ($formatSource) |
|
135 | 135 | { |
136 | 136 | $dom = new DOMDocument(); |
137 | 137 | $dom->preserveWhiteSpace = false; |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * @param bool $formatSource |
153 | 153 | * @return string |
154 | 154 | */ |
155 | - public static function html(string $html, bool $formatSource=false) : string |
|
155 | + public static function html(string $html, bool $formatSource = false) : string |
|
156 | 156 | { |
157 | - if($formatSource) |
|
157 | + if ($formatSource) |
|
158 | 158 | { |
159 | 159 | $dom = new DOMDocument(); |
160 | 160 | $dom->preserveWhiteSpace = false; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @throws JSONConverterException |
42 | 42 | * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
43 | 43 | */ |
44 | - public static function var2json($variable, int $options=0, int $depth=512) : string |
|
44 | + public static function var2json($variable, int $options = 0, int $depth = 512) : string |
|
45 | 45 | { |
46 | 46 | try |
47 | 47 | { |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @return mixed|NULL |
70 | 70 | * @throws JSONConverterException |
71 | 71 | */ |
72 | - public static function json2var(string $json, bool $assoc=true) |
|
72 | + public static function json2var(string $json, bool $assoc = true) |
|
73 | 73 | { |
74 | - if(empty($json)) { |
|
74 | + if (empty($json)) { |
|
75 | 75 | return null; |
76 | 76 | } |
77 | 77 | |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function json2array($json) : array |
114 | 114 | { |
115 | - if(is_array($json)) { |
|
115 | + if (is_array($json)) { |
|
116 | 116 | return $json; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $result = self::json2var($json); |
120 | - if(is_array($result)) { |
|
120 | + if (is_array($result)) { |
|
121 | 121 | return $result; |
122 | 122 | } |
123 | 123 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param int $depth |
166 | 166 | * @return string |
167 | 167 | */ |
168 | - public static function var2jsonSilent($variable, int $options=0, int $depth=512) : string |
|
168 | + public static function var2jsonSilent($variable, int $options = 0, int $depth = 512) : string |
|
169 | 169 | { |
170 | 170 | try |
171 | 171 | { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @param bool $assoc |
186 | 186 | * @return mixed|null |
187 | 187 | */ |
188 | - public static function json2varSilent(string $json, bool $assoc=true) |
|
188 | + public static function json2varSilent(string $json, bool $assoc = true) |
|
189 | 189 | { |
190 | 190 | try |
191 | 191 | { |
@@ -46,8 +46,7 @@ discard block |
||
46 | 46 | try |
47 | 47 | { |
48 | 48 | return json_encode($variable, JSON_THROW_ON_ERROR | $options, $depth); |
49 | - } |
|
50 | - catch (JsonException $e) |
|
49 | + } catch (JsonException $e) |
|
51 | 50 | { |
52 | 51 | throw new JSONConverterException( |
53 | 52 | 'Could not create json array'.json_last_error_msg(), |
@@ -78,8 +77,7 @@ discard block |
||
78 | 77 | try |
79 | 78 | { |
80 | 79 | return json_decode($json, $assoc, 512, JSON_THROW_ON_ERROR); |
81 | - } |
|
82 | - catch (JsonException $e) |
|
80 | + } catch (JsonException $e) |
|
83 | 81 | { |
84 | 82 | throw new JSONConverterException( |
85 | 83 | 'Could not decode JSON string.', |
@@ -149,8 +147,7 @@ discard block |
||
149 | 147 | try |
150 | 148 | { |
151 | 149 | return self::json2array($json); |
152 | - } |
|
153 | - catch (JSONConverterException $e) |
|
150 | + } catch (JSONConverterException $e) |
|
154 | 151 | { |
155 | 152 | return array(); |
156 | 153 | } |
@@ -170,8 +167,7 @@ discard block |
||
170 | 167 | try |
171 | 168 | { |
172 | 169 | return self::var2json($variable, $options, $depth); |
173 | - } |
|
174 | - catch (JSONConverterException $e) |
|
170 | + } catch (JSONConverterException $e) |
|
175 | 171 | { |
176 | 172 | return ''; |
177 | 173 | } |
@@ -190,8 +186,7 @@ discard block |
||
190 | 186 | try |
191 | 187 | { |
192 | 188 | return self::json2var($json, $assoc); |
193 | - } |
|
194 | - catch (JSONConverterException $e) |
|
189 | + } catch (JSONConverterException $e) |
|
195 | 190 | { |
196 | 191 | return null; |
197 | 192 | } |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | |
52 | 52 | protected SimpleXMLElement $xml; |
53 | 53 | |
54 | - /** |
|
55 | - * @var string|NULL |
|
56 | - */ |
|
54 | + /** |
|
55 | + * @var string|NULL |
|
56 | + */ |
|
57 | 57 | protected ?string $json; |
58 | 58 | |
59 | 59 | protected function __construct(SimpleXMLElement $element) |
@@ -98,34 +98,34 @@ discard block |
||
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
103 | - * |
|
104 | - * @param SimpleXMLElement $element |
|
105 | - * @return XMLHelper_Converter |
|
106 | - */ |
|
101 | + /** |
|
102 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
103 | + * |
|
104 | + * @param SimpleXMLElement $element |
|
105 | + * @return XMLHelper_Converter |
|
106 | + */ |
|
107 | 107 | public static function fromElement(SimpleXMLElement $element) : XMLHelper_Converter |
108 | 108 | { |
109 | 109 | return new XMLHelper_Converter($element); |
110 | 110 | } |
111 | 111 | |
112 | - /** |
|
113 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
114 | - * |
|
115 | - * @param DOMElement $element |
|
116 | - * @return XMLHelper_Converter |
|
117 | - */ |
|
112 | + /** |
|
113 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
114 | + * |
|
115 | + * @param DOMElement $element |
|
116 | + * @return XMLHelper_Converter |
|
117 | + */ |
|
118 | 118 | public static function fromDOMElement(DOMElement $element) : XMLHelper_Converter |
119 | 119 | { |
120 | 120 | return new XMLHelper_Converter(simplexml_import_dom($element)); |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Converts the XML to JSON. |
|
125 | - * |
|
126 | - * @return string |
|
127 | - * @throws XMLHelper_Exception |
|
128 | - */ |
|
123 | + /** |
|
124 | + * Converts the XML to JSON. |
|
125 | + * |
|
126 | + * @return string |
|
127 | + * @throws XMLHelper_Exception |
|
128 | + */ |
|
129 | 129 | public function toJSON() : string |
130 | 130 | { |
131 | 131 | if (isset($this->json)) |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | try |
87 | 87 | { |
88 | 88 | return self::fromElement(new SimpleXMLElement($xmlString)); |
89 | - } |
|
90 | - catch (Exception $e) |
|
89 | + } catch (Exception $e) |
|
91 | 90 | { |
92 | 91 | throw new XMLHelper_Exception( |
93 | 92 | 'Cannot create new element from string.', |
@@ -142,8 +141,7 @@ discard block |
||
142 | 141 | unset($this->xml); |
143 | 142 | |
144 | 143 | return $this->json; |
145 | - } |
|
146 | - catch (JSONConverterException $e) |
|
144 | + } catch (JSONConverterException $e) |
|
147 | 145 | { |
148 | 146 | throw new XMLHelper_Exception( |
149 | 147 | 'Could not convert the XML source to JSON.', |
@@ -171,8 +169,7 @@ discard block |
||
171 | 169 | try |
172 | 170 | { |
173 | 171 | return JSONConverter::json2array($this->toJSON()); |
174 | - } |
|
175 | - catch (JSONConverterException $e) |
|
172 | + } catch (JSONConverterException $e) |
|
176 | 173 | { |
177 | 174 | throw new XMLHelper_Exception( |
178 | 175 | 'Could not convert the JSON string to an array.', |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | private function convertEncoding(string $contents) : string |
124 | 124 | { |
125 | - if(!empty($this->targetEncoding)) |
|
125 | + if (!empty($this->targetEncoding)) |
|
126 | 126 | { |
127 | 127 | return (string)mb_convert_encoding( |
128 | 128 | $contents, |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | { |
145 | 145 | $options = 0; |
146 | 146 | |
147 | - if($pretty) |
|
147 | + if ($pretty) |
|
148 | 148 | { |
149 | 149 | $options = JSON_PRETTY_PRINT; |
150 | 150 | } |
@@ -95,8 +95,7 @@ discard block |
||
95 | 95 | 512, |
96 | 96 | JSON_THROW_ON_ERROR |
97 | 97 | ); |
98 | - } |
|
99 | - catch (JsonException $e) |
|
98 | + } catch (JsonException $e) |
|
100 | 99 | { |
101 | 100 | throw new FileHelper_Exception( |
102 | 101 | 'Cannot decode json data', |
@@ -156,8 +155,7 @@ discard block |
||
156 | 155 | $this->putContents($json); |
157 | 156 | |
158 | 157 | return $this; |
159 | - } |
|
160 | - catch (JSONConverterException $e) |
|
158 | + } catch (JSONConverterException $e) |
|
161 | 159 | { |
162 | 160 | throw new FileHelper_Exception( |
163 | 161 | 'An error occurred while encoding a data set to JSON.', |
@@ -38,27 +38,27 @@ discard block |
||
38 | 38 | public const JS_REGEX_JSON = 'json'; |
39 | 39 | |
40 | 40 | /** |
41 | - * @var array<string,string> |
|
42 | - */ |
|
41 | + * @var array<string,string> |
|
42 | + */ |
|
43 | 43 | protected static array $variableCache = array(); |
44 | 44 | protected static int $elementCounter = 0; |
45 | 45 | protected static string $idPrefix = 'E'; |
46 | 46 | |
47 | - /** |
|
48 | - * Builds a javascript statement. The first parameter is the |
|
49 | - * javascript function to call, any additional parameters are |
|
50 | - * used as arguments for the javascript function call. Variable |
|
51 | - * types are automagically converted to the javascript equivalents. |
|
52 | - * |
|
53 | - * Examples: |
|
54 | - * |
|
55 | - * // add an alert(); statement: |
|
56 | - * JSHelper::buildStatement('alert'); |
|
57 | - * |
|
58 | - * // add an alert('Alert text'); statement |
|
59 | - * JSHelper::buildStatement('alert', 'Alert text'); |
|
60 | - * |
|
61 | - */ |
|
47 | + /** |
|
48 | + * Builds a javascript statement. The first parameter is the |
|
49 | + * javascript function to call, any additional parameters are |
|
50 | + * used as arguments for the javascript function call. Variable |
|
51 | + * types are automagically converted to the javascript equivalents. |
|
52 | + * |
|
53 | + * Examples: |
|
54 | + * |
|
55 | + * // add an alert(); statement: |
|
56 | + * JSHelper::buildStatement('alert'); |
|
57 | + * |
|
58 | + * // add an alert('Alert text'); statement |
|
59 | + * JSHelper::buildStatement('alert', 'Alert text'); |
|
60 | + * |
|
61 | + */ |
|
62 | 62 | public static function buildStatement() : string |
63 | 63 | { |
64 | 64 | $args = func_get_args(); |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | return call_user_func_array(array(self::class, 'buildStatementQuoteStyle'), $args); |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * Like {@link JSHelper::buildStatement()}, but using single quotes |
|
71 | - * to make it possible to use the statement in an HTML tag attribute. |
|
72 | - * |
|
73 | - * @return string |
|
74 | - * @see JSHelper::buildStatement() |
|
75 | - */ |
|
69 | + /** |
|
70 | + * Like {@link JSHelper::buildStatement()}, but using single quotes |
|
71 | + * to make it possible to use the statement in an HTML tag attribute. |
|
72 | + * |
|
73 | + * @return string |
|
74 | + * @see JSHelper::buildStatement() |
|
75 | + */ |
|
76 | 76 | public static function buildStatementAttribute() : string |
77 | 77 | { |
78 | 78 | $args = func_get_args(); |
@@ -225,13 +225,13 @@ discard block |
||
225 | 225 | return self::phpVariable2JS($variable, self::QUOTE_STYLE_SINGLE); |
226 | 226 | } |
227 | 227 | |
228 | - /** |
|
229 | - * Generates a dynamic element ID to be used with dynamically generated |
|
230 | - * HTML code to tie in with clientside javascript when compact but unique |
|
231 | - * IDs are needed in a request. |
|
232 | - * |
|
233 | - * @return string |
|
234 | - */ |
|
228 | + /** |
|
229 | + * Generates a dynamic element ID to be used with dynamically generated |
|
230 | + * HTML code to tie in with clientside javascript when compact but unique |
|
231 | + * IDs are needed in a request. |
|
232 | + * |
|
233 | + * @return string |
|
234 | + */ |
|
235 | 235 | public static function nextElementID() : string |
236 | 236 | { |
237 | 237 | self::$elementCounter++; |
@@ -239,33 +239,33 @@ discard block |
||
239 | 239 | return self::$idPrefix . self::$elementCounter; |
240 | 240 | } |
241 | 241 | |
242 | - /** |
|
243 | - * Retrieves the ID prefix currently used. |
|
244 | - * |
|
245 | - * @return string |
|
246 | - */ |
|
242 | + /** |
|
243 | + * Retrieves the ID prefix currently used. |
|
244 | + * |
|
245 | + * @return string |
|
246 | + */ |
|
247 | 247 | public static function getIDPrefix() : string |
248 | 248 | { |
249 | 249 | return self::$idPrefix; |
250 | 250 | } |
251 | 251 | |
252 | - /** |
|
253 | - * Retrieves the value of the internal elements counter. |
|
254 | - * |
|
255 | - * @return integer |
|
256 | - */ |
|
252 | + /** |
|
253 | + * Retrieves the value of the internal elements counter. |
|
254 | + * |
|
255 | + * @return integer |
|
256 | + */ |
|
257 | 257 | public static function getElementCounter() : int |
258 | 258 | { |
259 | 259 | return self::$elementCounter; |
260 | 260 | } |
261 | 261 | |
262 | - /** |
|
263 | - * Sets the prefix that is added in front of all IDs |
|
264 | - * retrieved using the {@link nextElementID()} method. |
|
265 | - * |
|
266 | - * @param string $prefix |
|
267 | - * @see JSHelper::nextElementID() |
|
268 | - */ |
|
262 | + /** |
|
263 | + * Sets the prefix that is added in front of all IDs |
|
264 | + * retrieved using the {@link nextElementID()} method. |
|
265 | + * |
|
266 | + * @param string $prefix |
|
267 | + * @see JSHelper::nextElementID() |
|
268 | + */ |
|
269 | 269 | public static function setIDPrefix(string $prefix) : void |
270 | 270 | { |
271 | 271 | self::$idPrefix = $prefix; |
@@ -86,20 +86,20 @@ discard block |
||
86 | 86 | $quoteStyle = array_shift($params); |
87 | 87 | $method = array_shift($params); |
88 | 88 | |
89 | - $call = $method . '('; |
|
89 | + $call = $method.'('; |
|
90 | 90 | |
91 | 91 | $total = count($params); |
92 | - if($total > 0) { |
|
93 | - for($i=0; $i < $total; $i++) |
|
92 | + if ($total > 0) { |
|
93 | + for ($i = 0; $i < $total; $i++) |
|
94 | 94 | { |
95 | 95 | $call .= self::phpVariable2JS($params[$i], $quoteStyle); |
96 | - if($i < ($total-1)) { |
|
96 | + if ($i < ($total - 1)) { |
|
97 | 97 | $call .= ','; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - return $call . ');'; |
|
102 | + return $call.');'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public static function buildVariable(string $varName, $varValue) : string |
127 | 127 | { |
128 | - return $varName . "=" . self::phpVariable2JS($varValue) . ';'; |
|
128 | + return $varName."=".self::phpVariable2JS($varValue).';'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return string |
139 | 139 | * @throws JSONConverterException |
140 | 140 | */ |
141 | - public static function phpVariable2JS($variable, int $quoteStyle=self::QUOTE_STYLE_DOUBLE) : string |
|
141 | + public static function phpVariable2JS($variable, int $quoteStyle = self::QUOTE_STYLE_DOUBLE) : string |
|
142 | 142 | { |
143 | 143 | // after much profiling, this variant of the method offers |
144 | 144 | // the best performance. Repeat scalar values are cached |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | |
147 | 147 | $type = gettype($variable); |
148 | 148 | $hash = null; |
149 | - if(is_scalar($variable) === true) |
|
149 | + if (is_scalar($variable) === true) |
|
150 | 150 | { |
151 | 151 | $hash = $variable; |
152 | 152 | |
153 | - if($hash === true) |
|
153 | + if ($hash === true) |
|
154 | 154 | { |
155 | 155 | $hash = 'true'; |
156 | 156 | } |
157 | - else if($hash === false) |
|
157 | + else if ($hash === false) |
|
158 | 158 | { |
159 | 159 | $hash = 'false'; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $hash .= '-'.$quoteStyle.'-'.$type; |
163 | 163 | |
164 | - if(isset(self::$variableCache[$hash])) { |
|
164 | + if (isset(self::$variableCache[$hash])) { |
|
165 | 165 | return self::$variableCache[$hash]; |
166 | 166 | } |
167 | 167 | } |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | $result = 'null'; |
170 | 170 | |
171 | 171 | // one gettype call is better than a strict if-else. |
172 | - switch($type) |
|
172 | + switch ($type) |
|
173 | 173 | { |
174 | 174 | case 'double': |
175 | 175 | case 'string': |
176 | 176 | $string = JSONConverter::var2json($variable); |
177 | 177 | |
178 | - if($quoteStyle === self::QUOTE_STYLE_SINGLE) |
|
178 | + if ($quoteStyle === self::QUOTE_STYLE_SINGLE) |
|
179 | 179 | { |
180 | 180 | $string = mb_substr($string, 1, -1); |
181 | 181 | $string = "'".str_replace("'", "\'", $string)."'"; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | break; |
186 | 186 | |
187 | 187 | case 'boolean': |
188 | - if($variable === true) { |
|
188 | + if ($variable === true) { |
|
189 | 189 | $result = 'true'; |
190 | 190 | } else { |
191 | 191 | $result = 'false'; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | // cache cacheable values |
206 | - if($hash !== null) |
|
206 | + if ($hash !== null) |
|
207 | 207 | { |
208 | 208 | self::$variableCache[$hash] = $result; |
209 | 209 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | { |
237 | 237 | self::$elementCounter++; |
238 | 238 | |
239 | - return self::$idPrefix . self::$elementCounter; |
|
239 | + return self::$idPrefix.self::$elementCounter; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | * @see JSHelper::JS_REGEX_OBJECT |
310 | 310 | * @see JSHelper::JS_REGEX_JSON |
311 | 311 | */ |
312 | - public static function buildRegexStatement(string $regex, string $statementType=self::JS_REGEX_OBJECT) : string |
|
312 | + public static function buildRegexStatement(string $regex, string $statementType = self::JS_REGEX_OBJECT) : string |
|
313 | 313 | { |
314 | 314 | $regex = trim($regex); |
315 | 315 | |
316 | - if(empty($regex)) |
|
316 | + if (empty($regex)) |
|
317 | 317 | { |
318 | 318 | throw new JSHelperException( |
319 | 319 | 'Empty regex.', |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | array_shift($parts); |
328 | 328 | |
329 | 329 | $modifiers = array_pop($parts); |
330 | - if($modifiers === $separator) { |
|
330 | + if ($modifiers === $separator) { |
|
331 | 331 | $modifiers = ''; |
332 | 332 | } |
333 | 333 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | // convert the anchors that are not supported in js regexes |
348 | 348 | $format = str_replace(array('\\A', '\\Z', '\\z'), array('^', '$', ''), $format); |
349 | 349 | |
350 | - if($statementType === self::JS_REGEX_JSON) |
|
350 | + if ($statementType === self::JS_REGEX_JSON) |
|
351 | 351 | { |
352 | 352 | return ConvertHelper::var2json(array( |
353 | 353 | 'format' => $format, |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | )); |
356 | 356 | } |
357 | 357 | |
358 | - if(!empty($modifiers)) { |
|
358 | + if (!empty($modifiers)) { |
|
359 | 359 | return sprintf( |
360 | 360 | 'new RegExp(%s, %s)', |
361 | 361 | ConvertHelper::var2json($format), |
@@ -153,8 +153,7 @@ |
||
153 | 153 | if($hash === true) |
154 | 154 | { |
155 | 155 | $hash = 'true'; |
156 | - } |
|
157 | - else if($hash === false) |
|
156 | + } else if($hash === false) |
|
158 | 157 | { |
159 | 158 | $hash = 'false'; |
160 | 159 | } |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | 'WriteThreshold' => 100 |
41 | 41 | ); |
42 | 42 | |
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | 46 | protected $file; |
47 | 47 | |
48 | - /** |
|
49 | - * @var ZipArchive|NULL |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var ZipArchive|NULL |
|
50 | + */ |
|
51 | 51 | protected $zip; |
52 | 52 | |
53 | 53 | protected bool $open = false; |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | $this->file = $targetFile; |
58 | 58 | } |
59 | 59 | |
60 | - /** |
|
61 | - * Sets an option, among the available options: |
|
62 | - * |
|
63 | - * <ul> |
|
64 | - * <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> |
|
65 | - * </ul> |
|
66 | - * |
|
67 | - * @param string $name |
|
68 | - * @param mixed $value |
|
69 | - * @return ZIPHelper |
|
70 | - */ |
|
60 | + /** |
|
61 | + * Sets an option, among the available options: |
|
62 | + * |
|
63 | + * <ul> |
|
64 | + * <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> |
|
65 | + * </ul> |
|
66 | + * |
|
67 | + * @param string $name |
|
68 | + * @param mixed $value |
|
69 | + * @return ZIPHelper |
|
70 | + */ |
|
71 | 71 | public function setOption(string $name, $value) : ZIPHelper |
72 | 72 | { |
73 | 73 | $this->options[$name] = $value; |
74 | 74 | return $this; |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * Adds a file to the zip. By default, the file is stored |
|
79 | - * with the same name in the root of the zip. Use the optional |
|
80 | - * parameter to change the location in the zip. |
|
81 | - * |
|
82 | - * @param string $filePath |
|
83 | - * @param string|null $zipPath If no path is specified, file will be added with the same name in the ZIP's root. |
|
84 | - * @throws ZIPHelper_Exception |
|
85 | - * @return bool |
|
86 | - * |
|
87 | - * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
|
88 | - */ |
|
77 | + /** |
|
78 | + * Adds a file to the zip. By default, the file is stored |
|
79 | + * with the same name in the root of the zip. Use the optional |
|
80 | + * parameter to change the location in the zip. |
|
81 | + * |
|
82 | + * @param string $filePath |
|
83 | + * @param string|null $zipPath If no path is specified, file will be added with the same name in the ZIP's root. |
|
84 | + * @throws ZIPHelper_Exception |
|
85 | + * @return bool |
|
86 | + * |
|
87 | + * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
|
88 | + */ |
|
89 | 89 | public function addFile(string $filePath, ?string $zipPath=null) : bool |
90 | 90 | { |
91 | 91 | $this->open(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public const ERROR_SOURCE_FILE_DOES_NOT_EXIST = 338001; |
32 | 32 | public const ERROR_NO_FILES_IN_ARCHIVE = 338002; |
33 | 33 | public const ERROR_OPENING_ZIP_FILE = 338003; |
34 | - public const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
34 | + public const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @var array<string,mixed> |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
88 | 88 | */ |
89 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
89 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
90 | 90 | { |
91 | 91 | $this->open(); |
92 | 92 | |
@@ -134,16 +134,16 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function open() : void |
136 | 136 | { |
137 | - if($this->open) { |
|
137 | + if ($this->open) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | |
141 | - if(!isset($this->zip)) { |
|
141 | + if (!isset($this->zip)) { |
|
142 | 142 | $this->zip = new ZipArchive(); |
143 | 143 | } |
144 | 144 | |
145 | 145 | $flag = null; |
146 | - if(!file_exists($this->file)) { |
|
146 | + if (!file_exists($this->file)) { |
|
147 | 147 | $flag = ZipArchive::CREATE; |
148 | 148 | } |
149 | 149 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | $this->fileTracker++; |
188 | 188 | |
189 | - if($this->options['WriteThreshold'] < 1) { |
|
189 | + if ($this->options['WriteThreshold'] < 1) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | protected function close() : void |
205 | 205 | { |
206 | - if(!$this->open) { |
|
206 | + if (!$this->open) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | throw new ZIPHelper_Exception( |
213 | 213 | 'Could not save ZIP file to disk', |
214 | 214 | sprintf( |
215 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
216 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
215 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
216 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
217 | 217 | 'or trying to save to a directory that does not exist.', |
218 | 218 | $this->file |
219 | 219 | ), |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | $this->open(); |
234 | 234 | |
235 | - if($this->countFiles() < 1) |
|
235 | + if ($this->countFiles() < 1) |
|
236 | 236 | { |
237 | 237 | throw new ZIPHelper_Exception( |
238 | 238 | 'No files in the zip file', |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | * @throws ZIPHelper_Exception |
259 | 259 | * @return string The file name that was sent (useful in case none was specified). |
260 | 260 | */ |
261 | - public function download(?string $fileName=null) : string |
|
261 | + public function download(?string $fileName = null) : string |
|
262 | 262 | { |
263 | 263 | $this->save(); |
264 | 264 | |
265 | - if(empty($fileName)) |
|
265 | + if (empty($fileName)) |
|
266 | 266 | { |
267 | 267 | $fileName = basename($this->file); |
268 | 268 | } |
269 | 269 | |
270 | 270 | header('Content-type: application/zip'); |
271 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
272 | - header('Content-length: ' . filesize($this->file)); |
|
271 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
272 | + header('Content-length: '.filesize($this->file)); |
|
273 | 273 | header('Pragma: no-cache'); |
274 | 274 | header('Expires: 0'); |
275 | 275 | readfile($this->file); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @throws ZIPHelper_Exception |
288 | 288 | * @see ZIPHelper::download() |
289 | 289 | */ |
290 | - public function downloadAndDelete(?string $fileName=null) : ZIPHelper |
|
290 | + public function downloadAndDelete(?string $fileName = null) : ZIPHelper |
|
291 | 291 | { |
292 | 292 | $this->download($fileName); |
293 | 293 | |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | * @return boolean |
306 | 306 | * @throws ZIPHelper_Exception |
307 | 307 | */ |
308 | - public function extractAll(?string $outputFolder=null) : bool |
|
308 | + public function extractAll(?string $outputFolder = null) : bool |
|
309 | 309 | { |
310 | - if(empty($outputFolder)) { |
|
310 | + if (empty($outputFolder)) { |
|
311 | 311 | $outputFolder = dirname($this->file); |
312 | 312 | } |
313 | 313 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param RGBAColor|null $trimColor |
38 | 38 | * @throws ImageHelper_Exception |
39 | 39 | */ |
40 | - public function __construct(ImageHelper $helper, $sourceImage, ?RGBAColor $trimColor=null) |
|
40 | + public function __construct(ImageHelper $helper, $sourceImage, ?RGBAColor $trimColor = null) |
|
41 | 41 | { |
42 | 42 | ImageHelper::requireResource($sourceImage); |
43 | 43 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | $targetColor = ColorFactory::createAuto($trimColor); |
52 | 52 | |
53 | - if($targetColor !== null) |
|
53 | + if ($targetColor !== null) |
|
54 | 54 | { |
55 | 55 | return $targetColor; |
56 | 56 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | |
82 | - if($img !== false) { |
|
82 | + if ($img !== false) { |
|
83 | 83 | return $img; |
84 | 84 | } |
85 | 85 | |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | $ymax = null; |
100 | 100 | |
101 | 101 | // Start scanning for the edges. |
102 | - for ($iy=0; $iy<$imh; $iy++) |
|
102 | + for ($iy = 0; $iy < $imh; $iy++) |
|
103 | 103 | { |
104 | 104 | $first = true; |
105 | 105 | |
106 | - for ($ix=0; $ix<$imw; $ix++) |
|
106 | + for ($ix = 0; $ix < $imw; $ix++) |
|
107 | 107 | { |
108 | 108 | $ndx = imagecolorat($this->sourceImage, $ix, $iy); |
109 | 109 | $colors = $this->helper->getIndexedColors($this->sourceImage, $ndx); |
110 | 110 | |
111 | - if(!$colors->matchesAlpha($this->trimColor)) |
|
111 | + if (!$colors->matchesAlpha($this->trimColor)) |
|
112 | 112 | { |
113 | 113 | if ($xmin > $ix) { $xmin = $ix; } |
114 | 114 | if ($xmax < $ix) { $xmax = $ix; } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | $ymax = $iy; |
118 | 118 | |
119 | - if($first) |
|
119 | + if ($first) |
|
120 | 120 | { |
121 | 121 | $ix = $xmax; |
122 | 122 | $first = false; |
@@ -126,18 +126,18 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // no trimming border found |
129 | - if($ymax === null) { |
|
129 | + if ($ymax === null) { |
|
130 | 130 | return $this->sourceImage; |
131 | 131 | } |
132 | 132 | |
133 | 133 | // The new width and height of the image. |
134 | - $imw = 1+$xmax-$xmin; // Image width in pixels |
|
135 | - $imh = 1+$ymax-$ymin; // Image height in pixels |
|
134 | + $imw = 1 + $xmax - $xmin; // Image width in pixels |
|
135 | + $imh = 1 + $ymax - $ymin; // Image height in pixels |
|
136 | 136 | |
137 | 137 | // Make another image to place the trimmed version in. |
138 | 138 | $im2 = $this->helper->createNewImage($imw, $imh); |
139 | 139 | |
140 | - if($this->trimColor->hasTransparency()) |
|
140 | + if ($this->trimColor->hasTransparency()) |
|
141 | 141 | { |
142 | 142 | $bg2 = imagecolorallocatealpha( |
143 | 143 | $im2, |
@@ -148,8 +148,7 @@ |
||
148 | 148 | ); |
149 | 149 | |
150 | 150 | imagecolortransparent($im2, $bg2); |
151 | - } |
|
152 | - else |
|
151 | + } else |
|
153 | 152 | { |
154 | 153 | $bg2 = imagecolorallocate( |
155 | 154 | $im2, |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function setAttributes(array $attributes) : AttributeCollection |
79 | 79 | { |
80 | - foreach($attributes as $name => $value) |
|
80 | + foreach ($attributes as $name => $value) |
|
81 | 81 | { |
82 | 82 | $this->attr($name, $value); |
83 | 83 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return $this; |
86 | 86 | } |
87 | 87 | |
88 | - public function getAttribute(string $name, string $default='') : string |
|
88 | + public function getAttribute(string $name, string $default = '') : string |
|
89 | 89 | { |
90 | 90 | return $this->attributes[$name] ?? $default; |
91 | 91 | } |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | * @param array<string,string|number|bool|NULL|Interface_Stringable|StringBuilder_Interface> $attributes |
95 | 95 | * @return AttributeCollection |
96 | 96 | */ |
97 | - public static function create(array $attributes=array()) : AttributeCollection |
|
97 | + public static function create(array $attributes = array()) : AttributeCollection |
|
98 | 98 | { |
99 | 99 | return new AttributeCollection($attributes); |
100 | 100 | } |
101 | 101 | |
102 | - public function prop(string $name, bool $enabled=true) : AttributeCollection |
|
102 | + public function prop(string $name, bool $enabled = true) : AttributeCollection |
|
103 | 103 | { |
104 | - if($enabled) |
|
104 | + if ($enabled) |
|
105 | 105 | { |
106 | 106 | return $this->attr($name, $name); |
107 | 107 | } |
@@ -118,23 +118,23 @@ discard block |
||
118 | 118 | { |
119 | 119 | $string = Filtering::value2string($value); |
120 | 120 | |
121 | - if($name === 'class') |
|
121 | + if ($name === 'class') |
|
122 | 122 | { |
123 | 123 | return $this->addClasses(ConvertHelper::explodeTrim(' ', $string)); |
124 | 124 | } |
125 | 125 | |
126 | - if($name === 'style') |
|
126 | + if ($name === 'style') |
|
127 | 127 | { |
128 | 128 | $this->styles->parseStylesString($string); |
129 | 129 | return $this; |
130 | 130 | } |
131 | 131 | |
132 | - if($string !== '') |
|
132 | + if ($string !== '') |
|
133 | 133 | { |
134 | 134 | $this->attributes[$name] = $string; |
135 | 135 | |
136 | 136 | // remove it from the empty stack if it was empty before. |
137 | - if(in_array($name, $this->empty, true)) { |
|
137 | + if (in_array($name, $this->empty, true)) { |
|
138 | 138 | $this->empty = array_remove_values($this->empty, array($name)); |
139 | 139 | } |
140 | 140 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | { |
160 | 160 | $this->attr($name, $value); |
161 | 161 | |
162 | - if(isset($this->attributes[$name])) |
|
162 | + if (isset($this->attributes[$name])) |
|
163 | 163 | { |
164 | 164 | $this->attributes[$name] = Filtering::quotes($this->attributes[$name]); |
165 | 165 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | public function remove(string $name) : AttributeCollection |
176 | 176 | { |
177 | - if(isset($this->attributes[$name])) |
|
177 | + if (isset($this->attributes[$name])) |
|
178 | 178 | { |
179 | 179 | unset($this->attributes[$name]); |
180 | 180 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | private function getRenderer() : AttributesRenderer |
198 | 198 | { |
199 | - if(isset($this->renderer)) |
|
199 | + if (isset($this->renderer)) |
|
200 | 200 | { |
201 | 201 | return $this->renderer; |
202 | 202 | } |
@@ -230,12 +230,12 @@ discard block |
||
230 | 230 | $attributes = $this->attributes; |
231 | 231 | |
232 | 232 | // Are there any empty attributes to keep? |
233 | - if(!empty($this->keepEmpty)) |
|
233 | + if (!empty($this->keepEmpty)) |
|
234 | 234 | { |
235 | 235 | $names = array_keys($this->keepEmpty); |
236 | 236 | |
237 | - foreach($names as $name) { |
|
238 | - if(in_array($name, $this->empty, true)) { |
|
237 | + foreach ($names as $name) { |
|
238 | + if (in_array($name, $this->empty, true)) { |
|
239 | 239 | $attributes[$name] = ''; |
240 | 240 | } |
241 | 241 | } |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | return $attributes; |
245 | 245 | } |
246 | 246 | |
247 | - public function setKeepIfEmpty(string $name, bool $keep=true) : self |
|
247 | + public function setKeepIfEmpty(string $name, bool $keep = true) : self |
|
248 | 248 | { |
249 | - if($keep === true) |
|
249 | + if ($keep === true) |
|
250 | 250 | { |
251 | 251 | $this->keepEmpty[$name] = true; |
252 | 252 | } |
253 | - else if(isset($this->keepEmpty[$name])) |
|
253 | + else if (isset($this->keepEmpty[$name])) |
|
254 | 254 | { |
255 | 255 | unset($this->keepEmpty[$name]); |
256 | 256 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | |
300 | 300 | public const TARGET_BLANK = '_blank'; |
301 | 301 | |
302 | - public function target(string $value=self::TARGET_BLANK) : AttributeCollection |
|
302 | + public function target(string $value = self::TARGET_BLANK) : AttributeCollection |
|
303 | 303 | { |
304 | 304 | return $this->attr('target', $value); |
305 | 305 | } |
@@ -137,8 +137,7 @@ discard block |
||
137 | 137 | if(in_array($name, $this->empty, true)) { |
138 | 138 | $this->empty = array_remove_values($this->empty, array($name)); |
139 | 139 | } |
140 | - } |
|
141 | - else |
|
140 | + } else |
|
142 | 141 | { |
143 | 142 | unset($this->attributes[$name]); |
144 | 143 | |
@@ -249,8 +248,7 @@ discard block |
||
249 | 248 | if($keep === true) |
250 | 249 | { |
251 | 250 | $this->keepEmpty[$name] = true; |
252 | - } |
|
253 | - else if(isset($this->keepEmpty[$name])) |
|
251 | + } else if(isset($this->keepEmpty[$name])) |
|
254 | 252 | { |
255 | 253 | unset($this->keepEmpty[$name]); |
256 | 254 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param bool $selfClosing |
55 | 55 | * @return $this |
56 | 56 | */ |
57 | - public function setSelfClosing(bool $selfClosing=true) : self |
|
57 | + public function setSelfClosing(bool $selfClosing = true) : self |
|
58 | 58 | { |
59 | 59 | $this->selfClosing = $selfClosing; |
60 | 60 | return $this; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param bool $allowed |
70 | 70 | * @return $this |
71 | 71 | */ |
72 | - public function setEmptyAllowed(bool $allowed=true) : self |
|
72 | + public function setEmptyAllowed(bool $allowed = true) : self |
|
73 | 73 | { |
74 | 74 | $this->allowEmpty = $allowed; |
75 | 75 | return $this; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | public function isEmptyAllowed() : bool |
79 | 79 | { |
80 | - if($this->isSelfClosing()) |
|
80 | + if ($this->isSelfClosing()) |
|
81 | 81 | { |
82 | 82 | return true; |
83 | 83 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | return $this->allowEmpty; |
86 | 86 | } |
87 | 87 | |
88 | - public static function create(string $name, ?AttributeCollection $attributes=null) : HTMLTag |
|
88 | + public static function create(string $name, ?AttributeCollection $attributes = null) : HTMLTag |
|
89 | 89 | { |
90 | - if($attributes === null) |
|
90 | + if ($attributes === null) |
|
91 | 91 | { |
92 | 92 | $attributes = AttributeCollection::create(); |
93 | 93 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | public function render() : string |
115 | 115 | { |
116 | - if(!$this->isEmptyAllowed() && $this->isEmpty()) |
|
116 | + if (!$this->isEmptyAllowed() && $this->isEmpty()) |
|
117 | 117 | { |
118 | 118 | return ''; |
119 | 119 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | public static function getGlobalOptions() : GlobalOptions |
128 | 128 | { |
129 | - if(!isset(self::$globalOptions)) |
|
129 | + if (!isset(self::$globalOptions)) |
|
130 | 130 | { |
131 | 131 | self::$globalOptions = new GlobalOptions(); |
132 | 132 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | public function getSelfClosingChar() : string |
138 | 138 | { |
139 | - if($this->selfClosing && self::getGlobalOptions()->getSelfCloseStyle() === self::SELF_CLOSE_STYLE_SLASH) |
|
139 | + if ($this->selfClosing && self::getGlobalOptions()->getSelfCloseStyle() === self::SELF_CLOSE_STYLE_SLASH) |
|
140 | 140 | { |
141 | 141 | return '/'; |
142 | 142 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | public function renderClose() : string |
158 | 158 | { |
159 | - if($this->selfClosing) |
|
159 | + if ($this->selfClosing) |
|
160 | 160 | { |
161 | 161 | return ''; |
162 | 162 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | public function renderContent() : string |
202 | 202 | { |
203 | - if($this->selfClosing) |
|
203 | + if ($this->selfClosing) |
|
204 | 204 | { |
205 | 205 | return ''; |
206 | 206 | } |
@@ -219,11 +219,11 @@ discard block |
||
219 | 219 | * @param bool $keepIfEmpty |
220 | 220 | * @return $this |
221 | 221 | */ |
222 | - public function attr(string $name, string $value, bool $keepIfEmpty=false) : self |
|
222 | + public function attr(string $name, string $value, bool $keepIfEmpty = false) : self |
|
223 | 223 | { |
224 | 224 | $this->attributes->attr($name, $value); |
225 | 225 | |
226 | - if($keepIfEmpty) { |
|
226 | + if ($keepIfEmpty) { |
|
227 | 227 | $this->attributes->setKeepIfEmpty($name); |
228 | 228 | } |
229 | 229 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param bool $enabled |
236 | 236 | * @return $this |
237 | 237 | */ |
238 | - public function prop(string $name, bool $enabled=true) : self |
|
238 | + public function prop(string $name, bool $enabled = true) : self |
|
239 | 239 | { |
240 | 240 | $this->attributes->prop($name, $enabled); |
241 | 241 | return $this; |