From 5b97c50b2600103238ff71995bb5d861690973ee Mon Sep 17 00:00:00 2001 From: roadiz-ci Date: Fri, 12 Jul 2024 22:08:33 +0000 Subject: [PATCH] Merge tag v2.3.19 into develop --- src/Generators/MarkdownGeneratorFactory.php | 32 +++++++-------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/Generators/MarkdownGeneratorFactory.php b/src/Generators/MarkdownGeneratorFactory.php index b277298..c38925e 100644 --- a/src/Generators/MarkdownGeneratorFactory.php +++ b/src/Generators/MarkdownGeneratorFactory.php @@ -11,17 +11,10 @@ final class MarkdownGeneratorFactory { - private ParameterBag $nodeTypesBag; - private TranslatorInterface $translator; - - /** - * @param ParameterBag $nodeTypesBag - * @param TranslatorInterface $translator - */ - public function __construct(ParameterBag $nodeTypesBag, TranslatorInterface $translator) - { - $this->nodeTypesBag = $nodeTypesBag; - $this->translator = $translator; + public function __construct( + private readonly ParameterBag $nodeTypesBag, + private readonly TranslatorInterface $translator + ) { } public function getHumanBool(bool $bool): string @@ -50,16 +43,11 @@ public function createForNodeType(NodeTypeInterface $nodeType): NodeTypeGenerato */ public function createForNodeTypeField(NodeTypeFieldInterface $field): AbstractFieldGenerator { - switch (true) { - case $field->isNodes(): - return new NodeReferencesFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator); - case $field->isChildrenNodes(): - return new ChildrenNodeFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator); - case $field->isMultiple(): - case $field->isEnum(): - return new DefaultValuedFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator); - default: - return new CommonFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator); - } + return match (true) { + $field->isNodes() => new NodeReferencesFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator), + $field->isChildrenNodes() => new ChildrenNodeFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator), + $field->isMultiple(), $field->isEnum() => new DefaultValuedFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator), + default => new CommonFieldGenerator($this, $field, $this->nodeTypesBag, $this->translator), + }; } }