Skip to content

Commit

Permalink
Merge tag v2.3.19 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Jul 12, 2024
1 parent a3751d2 commit 5b97c50
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/Generators/MarkdownGeneratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
};
}
}

0 comments on commit 5b97c50

Please sign in to comment.