@@ -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; |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | * @param bool $forceNew |
| 13 | 13 | * @return NumberInfo |
| 14 | 14 | */ |
| 15 | -function parseNumber($value, bool $forceNew=false) |
|
| 15 | +function parseNumber($value, bool $forceNew = false) |
|
| 16 | 16 | { |
| 17 | - if($value instanceof NumberInfo && $forceNew !== true) { |
|
| 17 | + if ($value instanceof NumberInfo && $forceNew !== true) { |
|
| 18 | 18 | return $value; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $args = func_get_args(); |
| 110 | 110 | |
| 111 | 111 | // is the localization package installed? |
| 112 | - if(function_exists('\AppLocalize\t')) |
|
| 112 | + if (function_exists('\AppLocalize\t')) |
|
| 113 | 113 | { |
| 114 | 114 | return call_user_func_array('\AppLocalize\t', $args); |
| 115 | 115 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param bool $initial The initial boolean value to use. |
| 125 | 125 | * @return Value_Bool |
| 126 | 126 | */ |
| 127 | -function valBool(bool $initial=false) : Value_Bool |
|
| 127 | +function valBool(bool $initial = false) : Value_Bool |
|
| 128 | 128 | { |
| 129 | 129 | return new Value_Bool($initial); |
| 130 | 130 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param bool $initial |
| 138 | 138 | * @return Value_Bool_True |
| 139 | 139 | */ |
| 140 | -function valBoolTrue(bool $initial=false) : Value_Bool_True |
|
| 140 | +function valBoolTrue(bool $initial = false) : Value_Bool_True |
|
| 141 | 141 | { |
| 142 | 142 | return new Value_Bool_True($initial); |
| 143 | 143 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @param bool $initial |
| 151 | 151 | * @return Value_Bool_False |
| 152 | 152 | */ |
| 153 | -function valBoolFalse(bool $initial=true) : Value_Bool_False |
|
| 153 | +function valBoolFalse(bool $initial = true) : Value_Bool_False |
|
| 154 | 154 | { |
| 155 | 155 | return new Value_Bool_False($initial); |
| 156 | 156 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param bool $strict |
| 183 | 183 | * @return array<mixed> |
| 184 | 184 | */ |
| 185 | -function array_remove_values(array $haystack, array $values, bool $strict=true) : array |
|
| 185 | +function array_remove_values(array $haystack, array $values, bool $strict = true) : array |
|
| 186 | 186 | { |
| 187 | 187 | return array_filter( |
| 188 | 188 | $haystack, |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | function init() : void |
| 199 | 199 | { |
| 200 | - if(!class_exists('\AppLocalize\Localization')) { |
|
| 200 | + if (!class_exists('\AppLocalize\Localization')) { |
|
| 201 | 201 | return; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $attributes = $this->compileAttributes(); |
| 26 | 26 | |
| 27 | - if(empty($attributes)) |
|
| 27 | + if (empty($attributes)) |
|
| 28 | 28 | { |
| 29 | 29 | return ''; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - foreach($attributes as $name => $value) |
|
| 32 | + foreach ($attributes as $name => $value) |
|
| 33 | 33 | { |
| 34 | - if($value === '' && !$this->collection->isKeepIfEmpty($name)) |
|
| 34 | + if ($value === '' && !$this->collection->isKeepIfEmpty($name)) |
|
| 35 | 35 | { |
| 36 | 36 | continue; |
| 37 | 37 | } |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $attributes = $this->collection->getRawAttributes(); |
| 55 | 55 | |
| 56 | - if($this->collection->hasClasses()) |
|
| 56 | + if ($this->collection->hasClasses()) |
|
| 57 | 57 | { |
| 58 | 58 | $attributes['class'] = $this->collection->classesToString(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if($this->collection->hasStyles()) |
|
| 61 | + if ($this->collection->hasStyles()) |
|
| 62 | 62 | { |
| 63 | 63 | $attributes['style'] = $this->collection->getStyles() |
| 64 | 64 | ->configureForInline() |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | private function renderAttribute(string $name, string $value) : string |
| 72 | 72 | { |
| 73 | - if($name === $value) |
|
| 73 | + if ($name === $value) |
|
| 74 | 74 | { |
| 75 | 75 | return $name; |
| 76 | 76 | } |