GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BatchTimeType::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
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
namespace Core23\Form\Type;
13
14
use Core23\Form\Model\BatchTime;
15
use Symfony\Component\Form\AbstractType;
16
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
17
use Symfony\Component\Form\FormBuilderInterface;
18
use Symfony\Component\OptionsResolver\OptionsResolver;
19
20
final class BatchTimeType extends AbstractType
21
{
22
    /**
23
     * @var string
24
     */
25
    private $class;
26
27
    /**
28
     * @param string $class
29
     */
30
    public function __construct(string $class = null)
31
    {
32
        if (null === $class) {
33
            $class = BatchTime::class;
34
        } else {
35
            @trigger_error(
36
                'Passing a class as constructor argument is deprecated',
37
                E_USER_DEPRECATED
38
            );
39
        }
40
41
        $this->class = $class;
42
    }
43
44
    public function buildForm(FormBuilderInterface $builder, array $options): void
45
    {
46
        $emptyData = $builder->getEmptyData() ?: null;
47
48
        $builder
49
            ->add('day', ChoiceType::class, [
50
                'label'                     => 'form.input_batch_time_day',
51
                'choices'                   => range(0, 2),
52
                'choice_translation_domain' => false,
53
                'required'                  => $options['required'],
54
                'empty_data'                => $emptyData instanceof BatchTime ? $emptyData->getDay() : null,
55
            ])
56
            ->add('time', TimePickerType::class, [
57
                'label'                     => 'form.input_batch_time_time',
58
                'required'                  => $options['required'],
59
                'empty_data'                => $emptyData instanceof BatchTime ? $emptyData->getTime() : null,
60
            ])
61
        ;
62
    }
63
64
    public function getBlockPrefix()
65
    {
66
        return 'batch_time';
67
    }
68
69
    public function configureOptions(OptionsResolver $resolver): void
70
    {
71
        $resolver->setDefaults([
72
            'data_class' => $this->class,
73
            'compound'   => true,
74
        ]);
75
    }
76
}
77