@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function setAttributes(array $attributes) : AttributeCollection |
| 65 | 65 | { |
| 66 | - foreach($attributes as $name => $value) |
|
| 66 | + foreach ($attributes as $name => $value) |
|
| 67 | 67 | { |
| 68 | 68 | $this->attr($name, $value); |
| 69 | 69 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | return $this; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function getAttribute(string $name, string $default='') : string |
|
| 74 | + public function getAttribute(string $name, string $default = '') : string |
|
| 75 | 75 | { |
| 76 | 76 | return $this->attributes[$name] ?? $default; |
| 77 | 77 | } |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | * @param array<string,string|number> $attributes |
| 81 | 81 | * @return AttributeCollection |
| 82 | 82 | */ |
| 83 | - public static function create(array $attributes=array()) : AttributeCollection |
|
| 83 | + public static function create(array $attributes = array()) : AttributeCollection |
|
| 84 | 84 | { |
| 85 | 85 | return new AttributeCollection($attributes); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function prop(string $name, bool $enabled=true) : AttributeCollection |
|
| 88 | + public function prop(string $name, bool $enabled = true) : AttributeCollection |
|
| 89 | 89 | { |
| 90 | - if($enabled) |
|
| 90 | + if ($enabled) |
|
| 91 | 91 | { |
| 92 | 92 | return $this->attr($name, $name); |
| 93 | 93 | } |
@@ -104,18 +104,18 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | $string = Filtering::value2string($value); |
| 106 | 106 | |
| 107 | - if($name === 'class') |
|
| 107 | + if ($name === 'class') |
|
| 108 | 108 | { |
| 109 | 109 | return $this->addClasses(ConvertHelper::explodeTrim(' ', $string)); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if($name === 'style') |
|
| 112 | + if ($name === 'style') |
|
| 113 | 113 | { |
| 114 | 114 | $this->styles->parseStylesString($string); |
| 115 | 115 | return $this; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if($string !== '') |
|
| 118 | + if ($string !== '') |
|
| 119 | 119 | { |
| 120 | 120 | $this->attributes[$name] = $string; |
| 121 | 121 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $this->attr($name, $value); |
| 136 | 136 | |
| 137 | - if(isset($this->attributes[$name])) |
|
| 137 | + if (isset($this->attributes[$name])) |
|
| 138 | 138 | { |
| 139 | 139 | $this->attributes[$name] = Filtering::quotes($this->attributes[$name]); |
| 140 | 140 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | public function remove(string $name) : AttributeCollection |
| 151 | 151 | { |
| 152 | - if(isset($this->attributes[$name])) |
|
| 152 | + if (isset($this->attributes[$name])) |
|
| 153 | 153 | { |
| 154 | 154 | unset($this->attributes[$name]); |
| 155 | 155 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | private function getRenderer() : AttributesRenderer |
| 178 | 178 | { |
| 179 | - if(!isset($this->renderer)) |
|
| 179 | + if (!isset($this->renderer)) |
|
| 180 | 180 | { |
| 181 | 181 | $this->renderer = new AttributesRenderer($this); |
| 182 | 182 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | public const TARGET_BLANK = '_blank'; |
| 239 | 239 | |
| 240 | - public function target(string $value=self::TARGET_BLANK) : AttributeCollection |
|
| 240 | + public function target(string $value = self::TARGET_BLANK) : AttributeCollection |
|
| 241 | 241 | { |
| 242 | 242 | return $this->attr('target', $value); |
| 243 | 243 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @param array<string,string|number|NumberInfo|Interface_Stringable|NULL> $styles |
| 35 | 35 | */ |
| 36 | - public function __construct(array $styles=array()) |
|
| 36 | + public function __construct(array $styles = array()) |
|
| 37 | 37 | { |
| 38 | 38 | $this->options = new StyleOptions(); |
| 39 | 39 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param array<string,string|number|NumberInfo|Interface_Stringable|NULL> $styles |
| 45 | 45 | * @return StyleCollection |
| 46 | 46 | */ |
| 47 | - public static function create(array $styles=array()) : StyleCollection |
|
| 47 | + public static function create(array $styles = array()) : StyleCollection |
|
| 48 | 48 | { |
| 49 | 49 | return new StyleCollection($styles); |
| 50 | 50 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | { |
| 69 | 69 | $lines = explode(';', $string); |
| 70 | 70 | |
| 71 | - foreach($lines as $line) |
|
| 71 | + foreach ($lines as $line) |
|
| 72 | 72 | { |
| 73 | 73 | $parts = explode(':', $line); |
| 74 | 74 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function setStyles(array $styles) : StyleCollection |
| 91 | 91 | { |
| 92 | - foreach($styles as $name => $value) |
|
| 92 | + foreach ($styles as $name => $value) |
|
| 93 | 93 | { |
| 94 | 94 | $this->styleAuto($name, $value); |
| 95 | 95 | } |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | * @param bool $important |
| 106 | 106 | * @return $this |
| 107 | 107 | */ |
| 108 | - public function style(string $name, string $value, bool $important=false) : StyleCollection |
|
| 108 | + public function style(string $name, string $value, bool $important = false) : StyleCollection |
|
| 109 | 109 | { |
| 110 | - if($value === '') |
|
| 110 | + if ($value === '') |
|
| 111 | 111 | { |
| 112 | 112 | return $this; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if($important && stripos($value, '!important') === false) |
|
| 115 | + if ($important && stripos($value, '!important') === false) |
|
| 116 | 116 | { |
| 117 | 117 | $value .= ' !important'; |
| 118 | 118 | } |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | * @param bool $important |
| 131 | 131 | * @return $this |
| 132 | 132 | */ |
| 133 | - public function styleAuto(string $name, $value, bool $important=false) : StyleCollection |
|
| 133 | + public function styleAuto(string $name, $value, bool $important = false) : StyleCollection |
|
| 134 | 134 | { |
| 135 | - if($value instanceof NumberInfo) |
|
| 135 | + if ($value instanceof NumberInfo) |
|
| 136 | 136 | { |
| 137 | 137 | return $this->style($name, $value->toCSS(), $important); |
| 138 | 138 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | return $this->style($name, (string)$value, $important); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public function stylePX(string $name, int $px, bool $important=false) : StyleCollection |
|
| 143 | + public function stylePX(string $name, int $px, bool $important = false) : StyleCollection |
|
| 144 | 144 | { |
| 145 | 145 | return $this->style($name, $px.'px', $important); |
| 146 | 146 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param bool $important |
| 170 | 170 | * @return $this |
| 171 | 171 | */ |
| 172 | - public function styleParseNumber(string $name, $value, bool $important=false) : StyleCollection |
|
| 172 | + public function styleParseNumber(string $name, $value, bool $important = false) : StyleCollection |
|
| 173 | 173 | { |
| 174 | 174 | return $this->styleNumber($name, parseNumber($value), $important); |
| 175 | 175 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param bool $important |
| 183 | 183 | * @return $this |
| 184 | 184 | */ |
| 185 | - public function styleNumber(string $name, NumberInfo $info, bool $important=false) : StyleCollection |
|
| 185 | + public function styleNumber(string $name, NumberInfo $info, bool $important = false) : StyleCollection |
|
| 186 | 186 | { |
| 187 | 187 | $this->style($name, $info->toCSS(), $important); |
| 188 | 188 | return $this; |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | public function remove(string $name) : StyleCollection |
| 192 | 192 | { |
| 193 | - if(isset($this->styles[$name])) |
|
| 193 | + if (isset($this->styles[$name])) |
|
| 194 | 194 | { |
| 195 | 195 | unset($this->styles[$name]); |
| 196 | 196 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | $all = self::create(); |
| 228 | 228 | |
| 229 | - foreach($collections as $collection) |
|
| 229 | + foreach ($collections as $collection) |
|
| 230 | 230 | { |
| 231 | 231 | $all->mergeWith($collection); |
| 232 | 232 | } |
@@ -339,7 +339,7 @@ |
||
| 339 | 339 | */ |
| 340 | 340 | private function requireValidComponent(string $name) : void |
| 341 | 341 | { |
| 342 | - if(in_array($name, self::COLOR_COMPONENTS)) |
|
| 342 | + if (in_array($name, self::COLOR_COMPONENTS)) |
|
| 343 | 343 | { |
| 344 | 344 | return; |
| 345 | 345 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function addClass(string $name) |
| 43 | 43 | { |
| 44 | - if(!in_array($name, $this->classes)) { |
|
| 44 | + if (!in_array($name, $this->classes)) { |
|
| 45 | 45 | $this->classes[] = $name; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function addClasses(array $names) |
| 56 | 56 | { |
| 57 | - foreach($names as $name) { |
|
| 57 | + foreach ($names as $name) { |
|
| 58 | 58 | $this->addClass($name); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $idx = array_search($name, $this->classes); |
| 76 | 76 | |
| 77 | - if($idx !== false) { |
|
| 77 | + if ($idx !== false) { |
|
| 78 | 78 | unset($this->classes[$idx]); |
| 79 | 79 | sort($this->classes); |
| 80 | 80 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function classesToAttribute() : string |
| 110 | 110 | { |
| 111 | - if(!empty($this->classes)) |
|
| 111 | + if (!empty($this->classes)) |
|
| 112 | 112 | { |
| 113 | 113 | return sprintf( |
| 114 | 114 | ' class="%s" ', |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | * @param bool $enabled |
| 53 | 53 | * @return $this |
| 54 | 54 | */ |
| 55 | - public function prop(string $name, bool $enabled=true) |
|
| 55 | + public function prop(string $name, bool $enabled = true) |
|
| 56 | 56 | { |
| 57 | 57 | $this->getAttributes()->prop($name, $enabled); |
| 58 | 58 | return $this; |
@@ -56,11 +56,11 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | public static function value2string($value) : string |
| 58 | 58 | { |
| 59 | - if($value === true) |
|
| 59 | + if ($value === true) |
|
| 60 | 60 | { |
| 61 | 61 | return 'true'; |
| 62 | 62 | } |
| 63 | - else if($value === false) |
|
| 63 | + else if ($value === false) |
|
| 64 | 64 | { |
| 65 | 65 | return 'false'; |
| 66 | 66 | } |
@@ -59,8 +59,7 @@ |
||
| 59 | 59 | if($value === true) |
| 60 | 60 | { |
| 61 | 61 | return 'true'; |
| 62 | - } |
|
| 63 | - else if($value === false) |
|
| 62 | + } else if($value === false) |
|
| 64 | 63 | { |
| 65 | 64 | return 'false'; |
| 66 | 65 | } |
@@ -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 === '') |
|
| 34 | + if ($value === '') |
|
| 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 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | public function render() : string |
| 28 | 28 | { |
| 29 | - if($this->collection->hasStyles()) |
|
| 29 | + if ($this->collection->hasStyles()) |
|
| 30 | 30 | { |
| 31 | 31 | return implode( |
| 32 | 32 | $this->resolveSeparator(), |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | private function resolveSuffix() : string |
| 41 | 41 | { |
| 42 | - if($this->options->isTrailingSemicolonEnabled()) |
|
| 42 | + if ($this->options->isTrailingSemicolonEnabled()) |
|
| 43 | 43 | { |
| 44 | 44 | return ';'; |
| 45 | 45 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | private function resolveSeparator() : string |
| 51 | 51 | { |
| 52 | - if($this->options->isNewlineEnabled()) |
|
| 52 | + if ($this->options->isNewlineEnabled()) |
|
| 53 | 53 | { |
| 54 | 54 | return ';'.PHP_EOL; |
| 55 | 55 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $indentLevel = $this->options->getIndentLevel(); |
| 63 | 63 | |
| 64 | - if($indentLevel > 0) |
|
| 64 | + if ($indentLevel > 0) |
|
| 65 | 65 | { |
| 66 | 66 | return str_repeat($this->options->getIndentChar(), $indentLevel); |
| 67 | 67 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | private function resolveValueSpace() : string |
| 73 | 73 | { |
| 74 | - if($this->options->isSpaceBeforeValueEnabled()) |
|
| 74 | + if ($this->options->isSpaceBeforeValueEnabled()) |
|
| 75 | 75 | { |
| 76 | 76 | return ' '; |
| 77 | 77 | } |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | $indent = $this->resolveIndent(); |
| 87 | 87 | $valueSpace = $this->resolveValueSpace(); |
| 88 | 88 | |
| 89 | - if($this->options->isSortingEnabled()) |
|
| 89 | + if ($this->options->isSortingEnabled()) |
|
| 90 | 90 | { |
| 91 | 91 | ksort($styles); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - foreach($styles as $name => $value) |
|
| 94 | + foreach ($styles as $name => $value) |
|
| 95 | 95 | { |
| 96 | 96 | $lines[] = sprintf( |
| 97 | 97 | '%s%s:%s%s', |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | ); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function enableSorting(bool $enabled=true) : StyleOptions |
|
| 34 | + public function enableSorting(bool $enabled = true) : StyleOptions |
|
| 35 | 35 | { |
| 36 | 36 | return $this->setOption(self::OPTION_SORTING, $enabled); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function enableSpaceBeforeValue(bool $enabled=true) : StyleOptions |
|
| 39 | + public function enableSpaceBeforeValue(bool $enabled = true) : StyleOptions |
|
| 40 | 40 | { |
| 41 | 41 | return $this->setOption(self::OPTION_SPACE_BEFORE_VALUE, $enabled); |
| 42 | 42 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param bool $enabled |
| 46 | 46 | * @return $this |
| 47 | 47 | */ |
| 48 | - public function enableNewline(bool $enabled=true) : StyleOptions |
|
| 48 | + public function enableNewline(bool $enabled = true) : StyleOptions |
|
| 49 | 49 | { |
| 50 | 50 | return $this->setOption(self::OPTION_NEWLINES, $enabled); |
| 51 | 51 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | return $this->getStringOption(self::OPTION_INDENT_CHAR); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function enableTrailingSemicolon(bool $enabled=true) : StyleOptions |
|
| 121 | + public function enableTrailingSemicolon(bool $enabled = true) : StyleOptions |
|
| 122 | 122 | { |
| 123 | 123 | return $this->setOption(self::OPTION_TRAILING_SEMICOLON, $enabled); |
| 124 | 124 | } |