@@ -56,19 +56,19 @@ public function hsl(int $hue, int $saturatiom, int $lightness, int $alpha = 100)
5656 public function hex (string $ hex ): ?ColorHelper
5757 {
5858 if (preg_match (self ::PATTERN_HEX_SHORT , $ hex , $ matches )) {
59- $ red = hexdec ($ matches ['red ' ].$ matches ['red ' ]);
60- $ green = hexdec ($ matches ['green ' ].$ matches ['green ' ]);
61- $ blue = hexdec ($ matches ['blue ' ].$ matches ['blue ' ]);
62- $ alpha = hexdec (isset ($ matches ['alpha ' ]) ? $ matches ['alpha ' ].$ matches ['alpha ' ] : 1.0 );
59+ $ red = ( int ) hexdec ($ matches ['red ' ].$ matches ['red ' ]);
60+ $ green = ( int ) hexdec ($ matches ['green ' ].$ matches ['green ' ]);
61+ $ blue = ( int ) hexdec ($ matches ['blue ' ].$ matches ['blue ' ]);
62+ $ alpha = ( int ) hexdec (isset ($ matches ['alpha ' ]) ? $ matches ['alpha ' ].$ matches ['alpha ' ] : " ff " );
6363
6464 return new ColorHelper (
6565 new RgbaColor ($ red , $ green , $ blue , $ alpha )
6666 );
6767 } elseif (preg_match (self ::PATTERN_HEX_LONG , $ hex , $ matches )) {
68- $ red = hexdec ($ matches ['red ' ]);
69- $ green = hexdec ($ matches ['green ' ]);
70- $ blue = hexdec ($ matches ['blue ' ]);
71- $ alpha = hexdec ($ matches ['alpha ' ] ?? 1 );
68+ $ red = ( int ) hexdec ($ matches ['red ' ]);
69+ $ green = ( int ) hexdec ($ matches ['green ' ]);
70+ $ blue = ( int ) hexdec ($ matches ['blue ' ]);
71+ $ alpha = ( int ) hexdec ($ matches ['alpha ' ] ?? " ff " );
7272
7373 return new ColorHelper (
7474 new RgbaColor ($ red , $ green , $ blue , $ alpha )
@@ -88,19 +88,19 @@ public function hex(string $hex): ?ColorHelper
8888 public function css (string $ colorString ): ?ColorHelper
8989 {
9090 if (preg_match (self ::PATTERN_HEX_SHORT , $ colorString , $ matches )) {
91- $ red = hexdec ($ matches ['red ' ].$ matches ['red ' ]);
92- $ green = hexdec ($ matches ['green ' ].$ matches ['green ' ]);
93- $ blue = hexdec ($ matches ['blue ' ].$ matches ['blue ' ]);
94- $ alpha = hexdec (isset ($ matches ['alpha ' ]) ? $ matches ['alpha ' ].$ matches ['alpha ' ] : 1.0 );
91+ $ red = ( int ) hexdec ($ matches ['red ' ].$ matches ['red ' ]);
92+ $ green = ( int ) hexdec ($ matches ['green ' ].$ matches ['green ' ]);
93+ $ blue = ( int ) hexdec ($ matches ['blue ' ].$ matches ['blue ' ]);
94+ $ alpha = ( int ) hexdec (isset ($ matches ['alpha ' ]) ? $ matches ['alpha ' ].$ matches ['alpha ' ] : " ff " );
9595
9696 return new ColorHelper (
9797 new RgbaColor ($ red , $ green , $ blue , $ alpha )
9898 );
9999 } elseif (preg_match (self ::PATTERN_HEX_LONG , $ colorString , $ matches )) {
100- $ red = hexdec ($ matches ['red ' ]);
101- $ green = hexdec ($ matches ['green ' ]);
102- $ blue = hexdec ($ matches ['blue ' ]);
103- $ alpha = hexdec ($ matches ['alpha ' ] ?? 1 );
100+ $ red = ( int ) hexdec ($ matches ['red ' ]);
101+ $ green = ( int ) hexdec ($ matches ['green ' ]);
102+ $ blue = ( int ) hexdec ($ matches ['blue ' ]);
103+ $ alpha = ( int ) hexdec ($ matches ['alpha ' ] ? $ matches [ ' alpha ' ] : " ff " );
104104
105105 return new ColorHelper (
106106 new RgbaColor ($ red , $ green , $ blue , $ alpha )
0 commit comments