Completed
Push — master ( 738b67...b891e0 )
by Kamil
03:42 queued 03:07
created

ChannelBasedUnitFixedDiscountConfigurationType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configureOptions() 0 12 1
A getParent() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sylius\Bundle\CoreBundle\Form\Type\Promotion\Action;
15
16
use Sylius\Bundle\CoreBundle\Form\Type\ChannelCollectionType;
17
use Sylius\Bundle\PromotionBundle\Form\Type\Action\UnitFixedDiscountConfigurationType;
18
use Sylius\Component\Core\Model\ChannelInterface;
19
use Symfony\Component\Form\AbstractType;
20
use Symfony\Component\OptionsResolver\OptionsResolver;
21
22
/**
23
 * @author Kamil Kokot <[email protected]>
24
 */
25
final class ChannelBasedUnitFixedDiscountConfigurationType extends AbstractType
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function configureOptions(OptionsResolver $resolver): void
31
    {
32
        $resolver->setDefaults([
33
            'entry_type' => UnitFixedDiscountConfigurationType::class,
34
            'entry_options' => function (ChannelInterface $channel) {
35
                return [
36
                    'label' => $channel->getName(),
37
                    'currency' => $channel->getBaseCurrency()->getCode(),
38
                ];
39
            },
40
        ]);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getParent(): string
47
    {
48
        return ChannelCollectionType::class;
49
    }
50
}
51