Skip to content

Commit 3a147fd

Browse files
authored
[CLEANUP] Extract method Color::shouldRenderAsHex (#853)
Resolves #852.
1 parent c8a7b5f commit 3a147fd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Value/Color.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,7 @@ public function __toString(): string
224224

225225
public function render(OutputFormat $outputFormat): string
226226
{
227-
// Shorthand RGB color values
228-
if (
229-
$outputFormat->getRGBHashNotation()
230-
&& $this->getRealName() === 'rgb'
231-
&& $this->allComponentsAreNumbers()
232-
) {
227+
if ($this->shouldRenderAsHex($outputFormat)) {
233228
return $this->renderAsHex();
234229
}
235230

@@ -240,6 +235,14 @@ public function render(OutputFormat $outputFormat): string
240235
return parent::render($outputFormat);
241236
}
242237

238+
private function shouldRenderAsHex(OutputFormat $outputFormat): bool
239+
{
240+
return
241+
$outputFormat->getRGBHashNotation()
242+
&& $this->getRealName() === 'rgb'
243+
&& $this->allComponentsAreNumbers();
244+
}
245+
243246
/**
244247
* The function name is a concatenation of the array keys of the components, which is passed to the constructor.
245248
* However, this can be changed by calling {@see CSSFunction::setName},

0 commit comments

Comments
 (0)