@@ -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 | } |
@@ -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 | } |
@@ -21,18 +21,18 @@ |
||
21 | 21 | * @throws ColorException |
22 | 22 | * @see RGBAColor::ERROR_INVALID_HEX_LENGTH |
23 | 23 | */ |
24 | - public function parse(string $hex, string $name='') : RGBAColor |
|
24 | + public function parse(string $hex, string $name = '') : RGBAColor |
|
25 | 25 | { |
26 | 26 | $hex = ltrim($hex, '#'); // Remove the hash if present |
27 | 27 | $hex = strtoupper($hex); |
28 | 28 | $length = strlen($hex); |
29 | 29 | |
30 | - if($length === 3) |
|
30 | + if ($length === 3) |
|
31 | 31 | { |
32 | 32 | return $this->parseHEX3($hex, $name); |
33 | 33 | } |
34 | 34 | |
35 | - if($length === 6) |
|
35 | + if ($length === 6) |
|
36 | 36 | { |
37 | 37 | return $this->parseHEX6($hex, $name); |
38 | 38 | } |
@@ -9,9 +9,9 @@ |
||
9 | 9 | |
10 | 10 | declare(strict_types=1); |
11 | 11 | |
12 | -$autoload = __DIR__ . '/../vendor/autoload.php'; |
|
12 | +$autoload = __DIR__.'/../vendor/autoload.php'; |
|
13 | 13 | |
14 | -if(!file_exists($autoload)) |
|
14 | +if (!file_exists($autoload)) |
|
15 | 15 | { |
16 | 16 | die('<b>ERROR:</b> Autoloader not present. Please run composer install first.'); |
17 | 17 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | <br> |
43 | 43 | <?php |
44 | 44 | |
45 | - foreach($urls as $url) |
|
45 | + foreach ($urls as $url) |
|
46 | 46 | { |
47 | 47 | $info = parseURL($url); |
48 | 48 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function getPresetsManager() : PresetsManager |
40 | 40 | { |
41 | - if(!isset(self::$presets)) |
|
41 | + if (!isset(self::$presets)) |
|
42 | 42 | { |
43 | 43 | self::$presets = new PresetsManager(); |
44 | 44 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param string $name |
55 | 55 | * @return RGBAColor |
56 | 56 | */ |
57 | - public static function create(ColorChannel $red, ColorChannel $green, ColorChannel $blue, ?ColorChannel $opacity=null, string $name='') : RGBAColor |
|
57 | + public static function create(ColorChannel $red, ColorChannel $green, ColorChannel $blue, ?ColorChannel $opacity = null, string $name = '') : RGBAColor |
|
58 | 58 | { |
59 | - if($opacity === null) |
|
59 | + if ($opacity === null) |
|
60 | 60 | { |
61 | 61 | $opacity = ColorChannel::eightBit(255); |
62 | 62 | } |
@@ -83,31 +83,31 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function createAuto($subject) : ?RGBAColor |
85 | 85 | { |
86 | - if($subject instanceof RGBAColor) |
|
86 | + if ($subject instanceof RGBAColor) |
|
87 | 87 | { |
88 | 88 | return $subject; |
89 | 89 | } |
90 | 90 | |
91 | - if(is_array($subject)) |
|
91 | + if (is_array($subject)) |
|
92 | 92 | { |
93 | 93 | return self::createFrom8BitArray($subject); |
94 | 94 | } |
95 | 95 | |
96 | 96 | $hexOrPreset = (string)$subject; |
97 | 97 | |
98 | - if($hexOrPreset === '') |
|
98 | + if ($hexOrPreset === '') |
|
99 | 99 | { |
100 | 100 | return null; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $manager = self::getPresetsManager(); |
104 | 104 | |
105 | - if($manager->hasPreset($hexOrPreset)) |
|
105 | + if ($manager->hasPreset($hexOrPreset)) |
|
106 | 106 | { |
107 | 107 | return $manager->getPreset($hexOrPreset); |
108 | 108 | } |
109 | 109 | |
110 | - if(preg_match('/[a-f0-9]{3,8}/i', $hexOrPreset)) |
|
110 | + if (preg_match('/[a-f0-9]{3,8}/i', $hexOrPreset)) |
|
111 | 111 | { |
112 | 112 | return self::createFromHEX($hexOrPreset); |
113 | 113 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | { |
156 | 156 | $color = FormatsConverter::array2associative($color); |
157 | 157 | |
158 | - if(!isset($color[RGBAColor::CHANNEL_ALPHA])) |
|
158 | + if (!isset($color[RGBAColor::CHANNEL_ALPHA])) |
|
159 | 159 | { |
160 | 160 | $color[RGBAColor::CHANNEL_ALPHA] = 255; |
161 | 161 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @see RGBAColor::ERROR_INVALID_COLOR_COMPONENT |
181 | 181 | * @see RGBAColor::ERROR_INVALID_PERCENTAGE_VALUE |
182 | 182 | */ |
183 | - public static function createFromHEX(string $hex, string $name='') : RGBAColor |
|
183 | + public static function createFromHEX(string $hex, string $name = '') : RGBAColor |
|
184 | 184 | { |
185 | 185 | return FormatsConverter::hex2color($hex, $name); |
186 | 186 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @param string $name |
206 | 206 | * @return RGBAColor |
207 | 207 | */ |
208 | - public static function createPercent(float $red, float $green, float $blue, float $opacity=100, string $name='') : RGBAColor |
|
208 | + public static function createPercent(float $red, float $green, float $blue, float $opacity = 100, string $name = '') : RGBAColor |
|
209 | 209 | { |
210 | 210 | return new RGBAColor( |
211 | 211 | ColorChannel::percent($red), |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param string $name |
228 | 228 | * @return RGBAColor |
229 | 229 | */ |
230 | - public static function createCSS(int $red, int $green, int $blue, float $opacity=1, string $name='') : RGBAColor |
|
230 | + public static function createCSS(int $red, int $green, int $blue, float $opacity = 1, string $name = '') : RGBAColor |
|
231 | 231 | { |
232 | 232 | return self::create( |
233 | 233 | ColorChannel::eightBit($red), |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param string $name |
249 | 249 | * @return RGBAColor |
250 | 250 | */ |
251 | - public static function create8Bit(int $red, int $green, int $blue, int $opacity=255, string $name='') : RGBAColor |
|
251 | + public static function create8Bit(int $red, int $green, int $blue, int $opacity = 255, string $name = '') : RGBAColor |
|
252 | 252 | { |
253 | 253 | return self::create( |
254 | 254 | ColorChannel::eightBit($red), |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param string $name |
272 | 272 | * @return RGBAColor |
273 | 273 | */ |
274 | - public static function createGD(int $red, int $green, int $blue, int $opacity=127, string $name='') : RGBAColor |
|
274 | + public static function createGD(int $red, int $green, int $blue, int $opacity = 127, string $name = '') : RGBAColor |
|
275 | 275 | { |
276 | 276 | return self::create( |
277 | 277 | 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 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $this->validateValue($value); |
38 | 38 | |
39 | - if(strlen($value) === 1) |
|
39 | + if (strlen($value) === 1) |
|
40 | 40 | { |
41 | 41 | $value = str_repeat($value, 2); |
42 | 42 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $match = preg_match('/\A[0-9A-F]{1,2}\z/iU', $hex); |
55 | 55 | |
56 | - if($match !== false && $match > 0) |
|
56 | + if ($match !== false && $match > 0) |
|
57 | 57 | { |
58 | 58 | return; |
59 | 59 | } |
@@ -56,6 +56,6 @@ |
||
56 | 56 | |
57 | 57 | public function invert() : SevenBitChannel |
58 | 58 | { |
59 | - return ColorChannel::sevenBit(127-$this->value); |
|
59 | + return ColorChannel::sevenBit(127 - $this->value); |
|
60 | 60 | } |
61 | 61 | } |
@@ -41,6 +41,6 @@ |
||
41 | 41 | |
42 | 42 | public function invert() : PercentChannel |
43 | 43 | { |
44 | - return ColorChannel::percent(100-$this->value); |
|
44 | + return ColorChannel::percent(100 - $this->value); |
|
45 | 45 | } |
46 | 46 | } |