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.

NumberOutputType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 29
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getParent() 0 3 1
A buildForm() 0 7 1
A getBlockPrefix() 0 3 1
A configureOptions() 0 24 1
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 Symfony\Component\Form\AbstractType;
15
use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
16
use Symfony\Component\Form\FormBuilderInterface;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
19
final class NumberOutputType extends AbstractType
20
{
21
    public function buildForm(FormBuilderInterface $builder, array $options): void
22
    {
23
        $builder->addViewTransformer(
24
            new NumberToLocalizedStringTransformer(
25
                $options['precision'],
26
                $options['grouping'],
27
                $options['rounding_mode']
28
            )
29
        );
30
    }
31
32
    public function configureOptions(OptionsResolver $resolver): void
33
    {
34
        $resolver
35
            ->setDefaults([
36
                'precision'     => null,
37
                'grouping'      => false,
38
                'rounding_mode' => NumberToLocalizedStringTransformer::ROUND_HALF_UP,
39
                'suffix'        => '',
40
                'prefix'        => '',
41
                'required'      => false,
42
                'disabled'      => true,
43
            ])
44
            ->setAllowedTypes('precision', ['null', 'int'])
45
            ->setAllowedTypes('grouping', 'bool')
46
            ->setAllowedTypes('suffix', 'string')
47
            ->setAllowedTypes('prefix', 'string')
48
            ->setAllowedValues('rounding_mode', [
49
                NumberToLocalizedStringTransformer::ROUND_FLOOR,
50
                NumberToLocalizedStringTransformer::ROUND_DOWN,
51
                NumberToLocalizedStringTransformer::ROUND_HALF_DOWN,
52
                NumberToLocalizedStringTransformer::ROUND_HALF_EVEN,
53
                NumberToLocalizedStringTransformer::ROUND_HALF_UP,
54
                NumberToLocalizedStringTransformer::ROUND_UP,
55
                NumberToLocalizedStringTransformer::ROUND_CEILING,
56
            ])
57
        ;
58
    }
59
60
    public function getBlockPrefix()
61
    {
62
        return 'number_output';
63
    }
64
65
    public function getParent()
66
    {
67
        return OutputType::class;
68
    }
69
}
70