@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | private $collection; |
| 23 | 23 | |
| 24 | - private function __construct(?StyleCollection $collection=null) |
|
| 24 | + private function __construct(?StyleCollection $collection = null) |
|
| 25 | 25 | { |
| 26 | - if($collection === null) |
|
| 26 | + if ($collection === null) |
|
| 27 | 27 | { |
| 28 | 28 | $collection = StyleCollection::create(); |
| 29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $this->collection = $collection; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public static function create(?StyleCollection $collection=null) : StyleBuilder |
|
| 34 | + public static function create(?StyleCollection $collection = null) : StyleBuilder |
|
| 35 | 35 | { |
| 36 | 36 | return new StyleBuilder($collection); |
| 37 | 37 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | * @param bool $enabled |
| 35 | 35 | * @return $this |
| 36 | 36 | */ |
| 37 | - public function prop(string $name, bool $enabled=true); |
|
| 37 | + public function prop(string $name, bool $enabled = true); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @param string $name |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | public static function color2HEX(RGBAColor $color) : string |
| 41 | 41 | { |
| 42 | 42 | $hex = |
| 43 | - UnitsConverter::int2hex($color->getRed()->get8Bit()) . |
|
| 44 | - UnitsConverter::int2hex($color->getGreen()->get8Bit()) . |
|
| 43 | + UnitsConverter::int2hex($color->getRed()->get8Bit()). |
|
| 44 | + UnitsConverter::int2hex($color->getGreen()->get8Bit()). |
|
| 45 | 45 | UnitsConverter::int2hex($color->getBlue()->get8Bit()); |
| 46 | 46 | |
| 47 | - if($color->hasTransparency()) |
|
| 47 | + if ($color->hasTransparency()) |
|
| 48 | 48 | { |
| 49 | 49 | $hex .= UnitsConverter::int2hex($color->getOpacity()->get8Bit()); |
| 50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public static function color2CSS(RGBAColor $color) : string |
| 62 | 62 | { |
| 63 | - if($color->hasTransparency()) |
|
| 63 | + if ($color->hasTransparency()) |
|
| 64 | 64 | { |
| 65 | 65 | return sprintf( |
| 66 | 66 | 'rgba(%s, %s, %s, %s)', |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public static function requireValidColorArray(array $color) : void |
| 97 | 97 | { |
| 98 | - if(self::isColorArray($color)) |
|
| 98 | + if (self::isColorArray($color)) |
|
| 99 | 99 | { |
| 100 | 100 | return; |
| 101 | 101 | } |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | RGBAColor::CHANNEL_BLUE |
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | - foreach($keys as $key) |
|
| 130 | + foreach ($keys as $key) |
|
| 131 | 131 | { |
| 132 | - if(!isset($color[$key])) |
|
| 132 | + if (!isset($color[$key])) |
|
| 133 | 133 | { |
| 134 | 134 | return false; |
| 135 | 135 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public static function color2readable(RGBAColor $color) : string |
| 150 | 150 | { |
| 151 | - if($color->hasTransparency()) |
|
| 151 | + if ($color->hasTransparency()) |
|
| 152 | 152 | { |
| 153 | 153 | return sprintf( |
| 154 | 154 | 'RGBA(%s %s %s %s)', |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | * @throws ColorException |
| 192 | 192 | * @see RGBAColor::ERROR_INVALID_HEX_LENGTH |
| 193 | 193 | */ |
| 194 | - public static function hex2color(string $hex, string $name='') : RGBAColor |
|
| 194 | + public static function hex2color(string $hex, string $name = '') : RGBAColor |
|
| 195 | 195 | { |
| 196 | - if(!isset(self::$hexParser)) |
|
| 196 | + if (!isset(self::$hexParser)) |
|
| 197 | 197 | { |
| 198 | 198 | self::$hexParser = new HEXParser(); |
| 199 | 199 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | // If one associative key is present, we assume |
| 247 | 247 | // that the color array is already correct. |
| 248 | - if(isset($color[RGBAColor::CHANNEL_RED])) |
|
| 248 | + if (isset($color[RGBAColor::CHANNEL_RED])) |
|
| 249 | 249 | { |
| 250 | 250 | return $color; |
| 251 | 251 | } |
@@ -253,15 +253,15 @@ discard block |
||
| 253 | 253 | $values = array_values($color); |
| 254 | 254 | $result = array(); |
| 255 | 255 | |
| 256 | - foreach(self::$keys as $idx => $def) |
|
| 256 | + foreach (self::$keys as $idx => $def) |
|
| 257 | 257 | { |
| 258 | - if(isset($values[$idx])) |
|
| 258 | + if (isset($values[$idx])) |
|
| 259 | 259 | { |
| 260 | 260 | $result[$def['key']] = $values[$idx]; |
| 261 | 261 | continue; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if(!$def['mandatory']) |
|
| 264 | + if (!$def['mandatory']) |
|
| 265 | 265 | { |
| 266 | 266 | continue; |
| 267 | 267 | } |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | |
| 99 | 99 | public static function percent2Float(float $percent) : float |
| 100 | 100 | { |
| 101 | - return round($percent/100, self::$floatPrecision); |
|
| 101 | + return round($percent / 100, self::$floatPrecision); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | public static function float2percent(float $value) : float |
@@ -41,9 +41,9 @@ |
||
| 41 | 41 | { |
| 42 | 42 | $parts = array(RGBAColor::CHANNEL_RED, RGBAColor::CHANNEL_GREEN, RGBAColor::CHANNEL_BLUE); |
| 43 | 43 | |
| 44 | - foreach($parts as $part) |
|
| 44 | + foreach ($parts as $part) |
|
| 45 | 45 | { |
| 46 | - if($sourceColor->getColor($part)->get8Bit() !== $targetColor->getColor($part)->get8Bit()) |
|
| 46 | + if ($sourceColor->getColor($part)->get8Bit() !== $targetColor->getColor($part)->get8Bit()) |
|
| 47 | 47 | { |
| 48 | 48 | return false; |
| 49 | 49 | } |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | private function init() : void |
| 64 | 64 | { |
| 65 | - if(self::$initialized === true) |
|
| 65 | + if (self::$initialized === true) |
|
| 66 | 66 | { |
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $this |
| 71 | 71 | ->registerGlobalPreset(self::COLOR_WHITE, 255, 255, 255, 255) |
| 72 | - ->registerGlobalPreset(self::COLOR_BLACK, 0,0,0, 255) |
|
| 72 | + ->registerGlobalPreset(self::COLOR_BLACK, 0, 0, 0, 255) |
|
| 73 | 73 | ->registerGlobalPreset(self::COLOR_TRANSPARENT, 0, 0, 0, 0); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -89,16 +89,16 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $preset = null; |
| 91 | 91 | |
| 92 | - if(isset($this->customPresets[$name])) |
|
| 92 | + if (isset($this->customPresets[$name])) |
|
| 93 | 93 | { |
| 94 | 94 | $preset = $this->customPresets[$name]; |
| 95 | 95 | } |
| 96 | - else if(isset(self::$globalPresets[$name])) |
|
| 96 | + else if (isset(self::$globalPresets[$name])) |
|
| 97 | 97 | { |
| 98 | 98 | $preset = self::$globalPresets[$name]; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if($preset !== null) |
|
| 101 | + if ($preset !== null) |
|
| 102 | 102 | { |
| 103 | 103 | return ColorFactory::create( |
| 104 | 104 | ColorChannel::EightBit($preset[RGBAColor::CHANNEL_RED]), |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $this->requireNotGlobal($name); |
| 134 | 134 | |
| 135 | - if(!isset(self::$globalPresets[$name])) |
|
| 135 | + if (!isset(self::$globalPresets[$name])) |
|
| 136 | 136 | { |
| 137 | 137 | self::$globalPresets[$name] = array( |
| 138 | 138 | RGBAColor::CHANNEL_RED => $red, |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | ); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function registerPreset(string $name, int $red, int $green, int $blue, int $alpha=255) : PresetsManager |
|
| 157 | + public function registerPreset(string $name, int $red, int $green, int $blue, int $alpha = 255) : PresetsManager |
|
| 158 | 158 | { |
| 159 | 159 | $this->requireNotGlobal($name); |
| 160 | 160 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | private function requireNotGlobal(string $name) : void |
| 172 | 172 | { |
| 173 | - if(!isset(self::$globalPresets[$name])) |
|
| 173 | + if (!isset(self::$globalPresets[$name])) |
|
| 174 | 174 | { |
| 175 | 175 | return; |
| 176 | 176 | } |
@@ -92,8 +92,7 @@ |
||
| 92 | 92 | if(isset($this->customPresets[$name])) |
| 93 | 93 | { |
| 94 | 94 | $preset = $this->customPresets[$name]; |
| 95 | - } |
|
| 96 | - else if(isset(self::$globalPresets[$name])) |
|
| 95 | + } else if(isset(self::$globalPresets[$name])) |
|
| 97 | 96 | { |
| 98 | 97 | $preset = self::$globalPresets[$name]; |
| 99 | 98 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public static function getPresetsManager() : PresetsManager |
| 41 | 41 | { |
| 42 | - if(!isset(self::$presets)) |
|
| 42 | + if (!isset(self::$presets)) |
|
| 43 | 43 | { |
| 44 | 44 | self::$presets = new PresetsManager(); |
| 45 | 45 | } |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | * @param string $name |
| 56 | 56 | * @return RGBAColor |
| 57 | 57 | */ |
| 58 | - public static function create(ColorChannel $red, ColorChannel $green, ColorChannel $blue, ?ColorChannel $opacity=null, string $name='') : RGBAColor |
|
| 58 | + public static function create(ColorChannel $red, ColorChannel $green, ColorChannel $blue, ?ColorChannel $opacity = null, string $name = '') : RGBAColor |
|
| 59 | 59 | { |
| 60 | - if($opacity === null) |
|
| 60 | + if ($opacity === null) |
|
| 61 | 61 | { |
| 62 | 62 | $opacity = ColorChannel::EightBit(255); |
| 63 | 63 | } |
@@ -84,31 +84,31 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public static function createAuto($subject) : ?RGBAColor |
| 86 | 86 | { |
| 87 | - if($subject instanceof RGBAColor) |
|
| 87 | + if ($subject instanceof RGBAColor) |
|
| 88 | 88 | { |
| 89 | 89 | return $subject; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if(is_array($subject)) |
|
| 92 | + if (is_array($subject)) |
|
| 93 | 93 | { |
| 94 | 94 | return self::createFrom8BitArray($subject); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $hexOrPreset = (string)$subject; |
| 98 | 98 | |
| 99 | - if($hexOrPreset === '') |
|
| 99 | + if ($hexOrPreset === '') |
|
| 100 | 100 | { |
| 101 | 101 | return null; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | $manager = self::getPresetsManager(); |
| 105 | 105 | |
| 106 | - if($manager->hasPreset($hexOrPreset)) |
|
| 106 | + if ($manager->hasPreset($hexOrPreset)) |
|
| 107 | 107 | { |
| 108 | 108 | return $manager->getPreset($hexOrPreset); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if(preg_match('/[a-f0-9]{3,8}/i', $hexOrPreset)) |
|
| 111 | + if (preg_match('/[a-f0-9]{3,8}/i', $hexOrPreset)) |
|
| 112 | 112 | { |
| 113 | 113 | return self::createFromHEX($hexOrPreset); |
| 114 | 114 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | { |
| 157 | 157 | $color = FormatsConverter::array2associative($color); |
| 158 | 158 | |
| 159 | - if(!isset($color[RGBAColor::CHANNEL_ALPHA])) |
|
| 159 | + if (!isset($color[RGBAColor::CHANNEL_ALPHA])) |
|
| 160 | 160 | { |
| 161 | 161 | $color[RGBAColor::CHANNEL_ALPHA] = 255; |
| 162 | 162 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @see RGBAColor::ERROR_INVALID_COLOR_COMPONENT |
| 182 | 182 | * @see RGBAColor::ERROR_INVALID_PERCENTAGE_VALUE |
| 183 | 183 | */ |
| 184 | - public static function createFromHEX(string $hex, string $name='') : RGBAColor |
|
| 184 | + public static function createFromHEX(string $hex, string $name = '') : RGBAColor |
|
| 185 | 185 | { |
| 186 | 186 | return FormatsConverter::hex2color($hex, $name); |
| 187 | 187 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @param string $name |
| 207 | 207 | * @return RGBAColor |
| 208 | 208 | */ |
| 209 | - public static function createPercent(float $red, float $green, float $blue, float $opacity=100, string $name='') : RGBAColor |
|
| 209 | + public static function createPercent(float $red, float $green, float $blue, float $opacity = 100, string $name = '') : RGBAColor |
|
| 210 | 210 | { |
| 211 | 211 | return new RGBAColor( |
| 212 | 212 | ColorChannel::Percent($red), |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @param string $name |
| 229 | 229 | * @return RGBAColor |
| 230 | 230 | */ |
| 231 | - public static function createCSS(int $red, int $green, int $blue, float $opacity=1, string $name='') : RGBAColor |
|
| 231 | + public static function createCSS(int $red, int $green, int $blue, float $opacity = 1, string $name = '') : RGBAColor |
|
| 232 | 232 | { |
| 233 | 233 | return self::create( |
| 234 | 234 | ColorChannel::EightBit($red), |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @param string $name |
| 250 | 250 | * @return RGBAColor |
| 251 | 251 | */ |
| 252 | - public static function create8Bit(int $red, int $green, int $blue, int $opacity=255, string $name='') : RGBAColor |
|
| 252 | + public static function create8Bit(int $red, int $green, int $blue, int $opacity = 255, string $name = '') : RGBAColor |
|
| 253 | 253 | { |
| 254 | 254 | return self::create( |
| 255 | 255 | ColorChannel::EightBit($red), |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param string $name |
| 273 | 273 | * @return RGBAColor |
| 274 | 274 | */ |
| 275 | - public static function create7Bit(int $red, int $green, int $blue, int $opacity=127, string $name='') : RGBAColor |
|
| 275 | + public static function create7Bit(int $red, int $green, int $blue, int $opacity = 127, string $name = '') : RGBAColor |
|
| 276 | 276 | { |
| 277 | 277 | return self::create( |
| 278 | 278 | ColorChannel::EightBit($red), |
@@ -41,6 +41,6 @@ |
||
| 41 | 41 | |
| 42 | 42 | public function invert() : EightBitChannel |
| 43 | 43 | { |
| 44 | - return ColorChannel::EightBit(255-$this->value); |
|
| 44 | + return ColorChannel::EightBit(255 - $this->value); |
|
| 45 | 45 | } |
| 46 | 46 | } |
@@ -41,6 +41,6 @@ |
||
| 41 | 41 | |
| 42 | 42 | public function invert() : CSSOpacityChannel |
| 43 | 43 | { |
| 44 | - return ColorChannel::CSSOpacity(1-$this->value); |
|
| 44 | + return ColorChannel::CSSOpacity(1 - $this->value); |
|
| 45 | 45 | } |
| 46 | 46 | } |