Skip to content

Commit 61971b8

Browse files
authored
[CLEANUP] Add Color::getRealName method (#827)
The DocBlock should explain. Co-authored-by: Jake Hotson <[email protected]>
1 parent c26f4a3 commit 61971b8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Value/Color.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function render(OutputFormat $outputFormat): string
227227
// Shorthand RGB color values
228228
if (
229229
$outputFormat->getRGBHashNotation()
230-
&& \implode('', \array_keys($this->aComponents)) === 'rgb'
230+
&& $this->getRealName() === 'rgb'
231231
&& $this->allComponentsAreNumbers()
232232
) {
233233
$result = \sprintf(
@@ -242,6 +242,16 @@ public function render(OutputFormat $outputFormat): string
242242
return parent::render($outputFormat);
243243
}
244244

245+
/**
246+
* The function name is a concatenation of the array keys of the components, which is passed to the constructor.
247+
* However, this can be changed by calling {@see CSSFunction::setName},
248+
* so is not reliable in situations where it's necessary to determine the function name based on the components.
249+
*/
250+
private function getRealName(): string
251+
{
252+
return \implode('', \array_keys($this->aComponents));
253+
}
254+
245255
/**
246256
* Test whether all color components are absolute numbers (CSS type `number`), not percentages or anything else.
247257
* If any component is not an instance of `Size`, the method will also return `false`.

0 commit comments

Comments
 (0)