From 8508bde914e273cfab0aca83c0f145ec25d18cf7 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 6 Mar 2025 17:39:09 +0100 Subject: [PATCH] [CLEANUP] Improve some `OutputFormat` property and getter names As suggested in #1098. The setters are not changed a those are part of the public API. --- src/OutputFormat.php | 20 ++++++++++---------- src/OutputFormatter.php | 2 +- src/Value/Color.php | 2 +- tests/Unit/OutputFormatTest.php | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/OutputFormat.php b/src/OutputFormat.php index e70db43f4..e8efba52a 100644 --- a/src/OutputFormat.php +++ b/src/OutputFormat.php @@ -18,7 +18,7 @@ class OutputFormat * * @var bool */ - private $rgbHashNotation = true; + private $usesRgbHashNotation = true; /** * Declaration format @@ -27,7 +27,7 @@ class OutputFormat * * @var bool */ - private $semicolonAfterLastRule = true; + private $renderSemicolonAfterLastRule = true; /** * Spacing @@ -272,17 +272,17 @@ public function setStringQuotingType(string $quotingType): self /** * @internal */ - public function getRGBHashNotation(): bool + public function usesRgbHashNotation(): bool { - return $this->rgbHashNotation; + return $this->usesRgbHashNotation; } /** * @return $this fluent interface */ - public function setRGBHashNotation(bool $rgbHashNotation): self + public function setRGBHashNotation(bool $usesRgbHashNotation): self { - $this->rgbHashNotation = $rgbHashNotation; + $this->usesRgbHashNotation = $usesRgbHashNotation; return $this; } @@ -290,17 +290,17 @@ public function setRGBHashNotation(bool $rgbHashNotation): self /** * @internal */ - public function getSemicolonAfterLastRule(): bool + public function shouldRenderSemicolonAfterLastRule(): bool { - return $this->semicolonAfterLastRule; + return $this->renderSemicolonAfterLastRule; } /** * @return $this fluent interface */ - public function setSemicolonAfterLastRule(bool $semicolonAfterLastRule): self + public function setSemicolonAfterLastRule(bool $renderSemicolonAfterLastRule): self { - $this->semicolonAfterLastRule = $semicolonAfterLastRule; + $this->renderSemicolonAfterLastRule = $renderSemicolonAfterLastRule; return $this; } diff --git a/src/OutputFormatter.php b/src/OutputFormatter.php index 2eca21feb..f7fb17d60 100644 --- a/src/OutputFormatter.php +++ b/src/OutputFormatter.php @@ -191,7 +191,7 @@ public function implode(string $separator, array $values, bool $increaseLevel = public function removeLastSemicolon(string $string): string { - if ($this->outputFormat->getSemicolonAfterLastRule()) { + if ($this->outputFormat->shouldRenderSemicolonAfterLastRule()) { return $string; } diff --git a/src/Value/Color.php b/src/Value/Color.php index 996111b1d..d12af070f 100644 --- a/src/Value/Color.php +++ b/src/Value/Color.php @@ -248,7 +248,7 @@ public function render(OutputFormat $outputFormat): string private function shouldRenderAsHex(OutputFormat $outputFormat): bool { return - $outputFormat->getRGBHashNotation() + $outputFormat->usesRgbHashNotation() && $this->getRealName() === 'rgb' && $this->allComponentsAreNumbers(); } diff --git a/tests/Unit/OutputFormatTest.php b/tests/Unit/OutputFormatTest.php index 8792892d3..226dd0094 100644 --- a/tests/Unit/OutputFormatTest.php +++ b/tests/Unit/OutputFormatTest.php @@ -53,9 +53,9 @@ public function setStringQuotingTypeProvidesFluentInterface(): void /** * @test */ - public function getRGBHashNotationInitiallyReturnsTrue(): void + public function usesRgbHashNotationInitiallyReturnsTrue(): void { - self::assertTrue($this->subject->getRGBHashNotation()); + self::assertTrue($this->subject->usesRgbHashNotation()); } /** @@ -78,7 +78,7 @@ public function setRGBHashNotationSetsRGBHashNotation(bool $value): void { $this->subject->setRGBHashNotation($value); - self::assertSame($value, $this->subject->getRGBHashNotation()); + self::assertSame($value, $this->subject->usesRgbHashNotation()); } /** @@ -92,9 +92,9 @@ public function setRGBHashNotationProvidesFluentInterface(): void /** * @test */ - public function getSemicolonAfterLastRuleInitiallyReturnsTrue(): void + public function shouldRenderSemicolonAfterLastRuleInitiallyReturnsTrue(): void { - self::assertTrue($this->subject->getSemicolonAfterLastRule()); + self::assertTrue($this->subject->shouldRenderSemicolonAfterLastRule()); } /** @@ -106,7 +106,7 @@ public function setSemicolonAfterLastRuleSetsSemicolonAfterLastRule(bool $value) { $this->subject->setSemicolonAfterLastRule($value); - self::assertSame($value, $this->subject->getSemicolonAfterLastRule()); + self::assertSame($value, $this->subject->shouldRenderSemicolonAfterLastRule()); } /**