Skip to content

Commit 11f543f

Browse files
committed
Revert "Allow alpha in RGBA strings"
This reverts commit cc35690.
1 parent eb91c0f commit 11f543f

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

webapp/src/Utils/Utils.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,11 @@ public static function componentToHex(int $component): string
371371
/**
372372
* Convert an RGB triple into a CSS hex color.
373373
*
374-
* @param array{int, int, int}|array{int, int, int, int} $color
374+
* @param array{int, int, int} $color
375375
*/
376376
public static function rgbToHex(array $color): string
377377
{
378-
$result = '#';
379-
for (int i = 0; i<count($color); i++) {
380-
$result += static::componentToHex($color[$i]);
381-
}
382-
return $result;
378+
return "#" . static::componentToHex($color[0]) . static::componentToHex($color[1]) . static::componentToHex($color[2]);
383379
}
384380

385381
public static function relativeLuminance(string $rgb): float

webapp/tests/Unit/Utils/UtilsTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,6 @@ public function testRgbToHex(): void
341341
self::assertEquals('#000000', Utils::rgbToHex([0, 0, 0]));
342342
self::assertEquals('#abcdef', Utils::rgbToHex([171, 205, 239]));
343343
self::assertEquals('#fedcba', Utils::rgbToHex([254, 220, 186]));
344-
self::assertEquals('#fedcbaff', Utils::rgbToHex([254, 220, 186, 255]));
345-
self::assertEquals('#fedcba00', Utils::rgbToHex([254, 220, 186, 0]));
346344
}
347345

348346
public function testRelativeLuminance(): void

0 commit comments

Comments
 (0)