Passed
Pull Request — master (#402)
by
unknown
04:26
created

BlockFixture::createArrayOfScalars()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusCmsPlugin\Fixture;
12
13
use BitBag\SyliusCmsPlugin\Fixture\Factory\FixtureFactoryInterface;
14
use Sylius\Bundle\FixturesBundle\Fixture\AbstractFixture;
15
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
16
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
17
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;
18
19
final class BlockFixture extends AbstractFixture
20
{
21
    /** @var FixtureFactoryInterface */
22
    private $blockFixtureFactory;
23
24
    public function __construct(FixtureFactoryInterface $blockFixtureFactory)
25
    {
26
        $this->blockFixtureFactory = $blockFixtureFactory;
27
    }
28
29
    public function load(array $options): void
30
    {
31
        $this->blockFixtureFactory->load($options['custom']);
32
    }
33
34
    public function getName(): string
35
    {
36
        return 'block';
37
    }
38
39
    protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void
40
    {
41
        $optionsNode
42
            ->children()
43
                ->arrayNode('custom')
44
                    ->arrayPrototype()
45
                        ->children()
46
                            ->booleanNode('remove_existing')->defaultTrue()->end()
47
                            ->integerNode('number')->defaultNull()->end()
0 ignored issues
show
Bug introduced by
The method integerNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
                            ->/** @scrutinizer ignore-call */ integerNode('number')->defaultNull()->end()
Loading history...
48
                            ->booleanNode('last_four_products')->defaultFalse()->end()
49
                            ->booleanNode('enabled')->defaultTrue()->end()
50
                            ->integerNode('products')->defaultNull()->end()
51
                            ->append($this->createArrayOfScalars('productCodes'))
52
                            ->append($this->createArrayOfScalars('taxons'))
53
                            ->append($this->createArrayOfScalars('sections'))
54
                            ->append($this->createArrayOfScalars('channels'))
55
                            ->append($this->translationsConfiguration())
56
                        ->end()
57
                    ->end()
58
                ->end()
59
            ->end()
60
        ;
61
    }
62
63
    private function createArrayOfScalars(string $name): NodeDefinition
64
    {
65
        $nodeDefinition = new ScalarNodeDefinition($name);
66
        $nodeDefinition->defaultNull()->end();
67
68
        return $nodeDefinition;
69
    }
70
71
    private function translationsConfiguration(): NodeDefinition
72
    {
73
        $translationsNodeDefinition = new ArrayNodeDefinition('translations');
74
        $translationsNodeDefinition
75
            ->arrayPrototype()
76
                ->children()
77
                    ->scalarNode('name')->end()
78
                    ->scalarNode('content')->end()
0 ignored issues
show
Bug introduced by
The method scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

78
                    ->/** @scrutinizer ignore-call */ scalarNode('content')->end()
Loading history...
79
                    ->scalarNode('link')->end()
80
                    ->scalarNode('image_path')->end()
81
                ->end()
82
            ->end()
83
        ;
84
85
        return $translationsNodeDefinition;
86
    }
87
}
88