File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -528,7 +528,7 @@ private static function sanitizeHex(string $hex): string
528528 $ color = str_replace ("# " , "" , $ hex );
529529
530530 // Validate hex string
531- if (!preg_match ('/^[a-fA-F0-9]+$/ ' , $ hex )) {
531+ if (!preg_match ('/^[a-fA-F0-9]+$/ ' , $ color )) {
532532 throw new Exception ("HEX color does not match format " );
533533 }
534534
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ require __DIR__ . '/bootstrap.php ' ;
4+
5+ use Mexitek \PHPColors \Color ;
6+ use Tester \Assert ;
7+
8+ // Test that a hex starting with '#' is supported as input
9+ $ expected = array (
10+ "#ffffff " ,
11+ "#00ff00 " ,
12+ "#000000 " ,
13+ "#ff9a00 " ,
14+ );
15+
16+ foreach ($ expected as $ input ) {
17+ $ color = new Color ($ input );
18+ Assert::same ((string ) $ color , $ input , 'Incorrect color returned. ' );
19+ }
You can’t perform that action at this time.
0 commit comments