Completed
Push — master ( 663845...79fb76 )
by Igor
18s queued 13s
created

Configuration::buildViewClassesNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 23
nc 1
nop 1
dl 0
loc 25
rs 9.552
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusLagersystemPlugin\DependencyInjection;
6
7
use function method_exists;
8
use Setono\SyliusLagersystemPlugin\View;
9
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
10
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
11
use Symfony\Component\Config\Definition\ConfigurationInterface;
12
13
final class Configuration implements ConfigurationInterface
14
{
15
    public function getConfigTreeBuilder(): TreeBuilder
16
    {
17
        $treeBuilder = new TreeBuilder('setono_sylius_lagersystem');
18
        if (method_exists($treeBuilder, 'getRootNode')) {
19
            $rootNode = $treeBuilder->getRootNode();
20
        } else {
21
            // BC layer for symfony/config 4.1 and older
22
            $rootNode = $treeBuilder->root('setono_sylius_lagersystem');
0 ignored issues
show
Deprecated Code introduced by
The function Symfony\Component\Config...der\TreeBuilder::root() has been deprecated: since Symfony 4.3, pass the root name to the constructor instead ( Ignorable by Annotation )

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

22
            $rootNode = /** @scrutinizer ignore-deprecated */ $treeBuilder->root('setono_sylius_lagersystem');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
23
        }
24
25
        $this->buildViewClassesNode($rootNode);
26
27
        return $treeBuilder;
28
    }
29
30
    private function buildViewClassesNode(ArrayNodeDefinition $rootNode): void
31
    {
32
        $rootNode
33
            ->addDefaultsIfNotSet()
34
            ->children()
35
                ->arrayNode('view_classes')
36
                    ->addDefaultsIfNotSet()
37
                    ->children()
38
                        ->scalarNode('page')->defaultValue(View\PageView::class)->end()
39
                        ->scalarNode('page_links')->defaultValue(View\PageLinksView::class)->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

39
                        ->/** @scrutinizer ignore-call */ scalarNode('page_links')->defaultValue(View\PageLinksView::class)->end()
Loading history...
40
                        ->scalarNode('image')->defaultValue(View\Image\ImageView::class)->end()
41
                        ->scalarNode('customer')->defaultValue(View\Customer\CustomerView::class)->end()
42
                        ->scalarNode('address')->defaultValue(View\AddressView::class)->end()
43
                        ->scalarNode('shipping_method')->defaultValue(View\ShippingMethodView::class)->end()
44
                        ->scalarNode('shipment')->defaultValue(View\ShipmentView::class)->end()
45
                        ->scalarNode('payment_method')->defaultValue(View\PaymentMethodView::class)->end()
46
                        ->scalarNode('payment')->defaultValue(View\PaymentView::class)->end()
47
                        ->scalarNode('adjustment')->defaultValue(View\Order\AdjustmentView::class)->end()
48
                        ->scalarNode('order')->defaultValue(View\Order\OrderView::class)->end()
49
                        ->scalarNode('order_item')->defaultValue(View\Order\ItemView::class)->end()
50
                        ->scalarNode('order_item_unit')->defaultValue(View\Order\ItemUnitView::class)->end()
51
                        ->scalarNode('product_variant')->defaultValue(View\Product\ProductVariantView::class)->end()
52
                    ->end()
53
                ->end()
54
            ->end()
55
        ;
56
    }
57
}
58