Skip to content

Commit 663992a

Browse files
authored
[TASK] Use type-safe setters in OutputFormat factory methods (#930)
Also add one more test for good measure.
1 parent 6cb27fa commit 663992a

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/OutputFormat.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -820,12 +820,18 @@ public static function create(): self
820820
public static function createCompact(): self
821821
{
822822
$format = self::create();
823-
$format->set('Space*Rules', '')
824-
->set('Space*Blocks', '')
823+
$format
824+
->setSpaceBeforeRules('')
825+
->setSpaceBetweenRules('')
826+
->setSpaceAfterRules('')
827+
->setSpaceBeforeBlocks('')
828+
->setSpaceBetweenBlocks('')
829+
->setSpaceAfterBlocks('')
825830
->setSpaceAfterRuleName('')
826831
->setSpaceBeforeOpeningBrace('')
827832
->setSpaceAfterSelectorSeparator('')
828833
->setRenderComments(false);
834+
829835
return $format;
830836
}
831837

@@ -835,11 +841,16 @@ public static function createCompact(): self
835841
public static function createPretty(): self
836842
{
837843
$format = self::create();
838-
$format->set('Space*Rules', "\n")
839-
->set('Space*Blocks', "\n")
844+
$format
845+
->setSpaceBeforeRules("\n")
846+
->setSpaceBetweenRules("\n")
847+
->setSpaceAfterRules("\n")
848+
->setSpaceBeforeBlocks("\n")
840849
->setSpaceBetweenBlocks("\n\n")
841-
->set('SpaceAfterListArgumentSeparators', [',' => ' '])
850+
->setSpaceAfterBlocks("\n")
851+
->setSpaceAfterListArgumentSeparators([',' => ' '])
842852
->setRenderComments(true);
853+
843854
return $format;
844855
}
845856
}

tests/Unit/OutputFormatTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,14 @@ public function createReturnsOutputFormatInstance(): void
896896
self::assertInstanceOf(OutputFormat::class, OutputFormat::create());
897897
}
898898

899+
/**
900+
* @test
901+
*/
902+
public function createCreatesInstanceWithDefaultSettings(): void
903+
{
904+
self::assertEquals(new OutputFormat(), OutputFormat::create());
905+
}
906+
899907
/**
900908
* @test
901909
*/

0 commit comments

Comments
 (0)