IntervalChoiceType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configureOptions() 0 8 1
A getParent() 0 4 1
A getBlockPrefix() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PH\Bundle\SubscriptionBundle\Form\Type;
6
7
use PH\Bundle\SubscriptionBundle\Provider\SubscriptionIntervalsProviderInterface;
8
use Symfony\Component\Form\AbstractType;
9
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
10
use Symfony\Component\OptionsResolver\OptionsResolver;
11
12
final class IntervalChoiceType extends AbstractType
13
{
14
    /**
15
     * @var SubscriptionIntervalsProviderInterface
16
     */
17
    private $subscriptionIntervalsProvider;
18
19
    /**
20
     * IntervalChoiceType constructor.
21
     *
22
     * @param SubscriptionIntervalsProviderInterface $subscriptionIntervalsProvider
23
     */
24
    public function __construct(SubscriptionIntervalsProviderInterface $subscriptionIntervalsProvider)
25
    {
26
        $this->subscriptionIntervalsProvider = $subscriptionIntervalsProvider;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function configureOptions(OptionsResolver $resolver): void
33
    {
34
        $resolver
35
            ->setDefaults([
36
                'choices' => $this->subscriptionIntervalsProvider->getIntervals(),
37
            ])
38
        ;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getParent(): string
45
    {
46
        return ChoiceType::class;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getBlockPrefix(): string
53
    {
54
        return 'ph_interval_choice';
55
    }
56
}
57