Completed
Push — master ( 823f1c...5ca85f )
by Rafał
08:28
created

StartDateChoiceType::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PH\Bundle\SubscriptionBundle\Form\Type;
6
7
use PH\Bundle\SubscriptionBundle\Provider\StartDateProviderInterface;
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 StartDateChoiceType extends AbstractType
13
{
14
    /**
15
     * @var StartDateProviderInterface
16
     */
17
    private $startDateProvider;
18
19
    /**
20
     * StartDateChoiceType constructor.
21
     *
22
     * @param StartDateProviderInterface $startDateProvider
23
     */
24
    public function __construct(StartDateProviderInterface $startDateProvider)
25
    {
26
        $this->startDateProvider = $startDateProvider;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function configureOptions(OptionsResolver $resolver): void
33
    {
34
        $resolver
35
            ->setDefaults([
36
                'choices' => $this->startDateProvider->getStartDates(),
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_start_date_choice';
55
    }
56
}
57