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.

HelpTypeExtension   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configureOptions() 0 19 3
A buildView() 0 10 3
A getExtendedTypes() 0 4 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\Extension;
13
14
use Symfony\Component\Form\AbstractTypeExtension;
15
use Symfony\Component\Form\Extension\Core\Type\FormType;
16
use Symfony\Component\Form\FormInterface;
17
use Symfony\Component\Form\FormView;
18
use Symfony\Component\OptionsResolver\Options;
19
use Symfony\Component\OptionsResolver\OptionsResolver;
20
21
/**
22
 * @deprecated Use the symfony help extension
23
 * @see https://symfony.com/doc/current/form/form_customization.html#form-help-form-view
24
 */
25
final class HelpTypeExtension extends AbstractTypeExtension
26
{
27
    public function buildView(FormView $view, FormInterface $form, array $options): void
28
    {
29
        $helpTranslationDomain = $options['help_translation_domain'];
30
        if ($view->parent && null === $helpTranslationDomain) {
31
            $helpTranslationDomain = $view->vars['translation_domain'];
32
        }
33
34
        $view->vars = array_replace($view->vars, [
35
            'help'                    => $options['help'],
36
            'help_translation_domain' => $helpTranslationDomain,
37
        ]);
38
    }
39
40
    public function configureOptions(OptionsResolver $resolver): void
41
    {
42
        $helpTranslationDomainNormalizer = static function (Options $options, $helpTranslationDomain) {
43
            if (null === $helpTranslationDomain && $options->offsetExists('translation_domain')) {
44
                return $options->offsetGet('translation_domain');
45
            }
46
47
            return $helpTranslationDomain;
48
        };
49
50
        $resolver->setDefaults([
51
            'help'                    => null,
52
            'help_translation_domain' => null,
53
        ]);
54
55
        $resolver->setNormalizer('help_translation_domain', $helpTranslationDomainNormalizer);
56
57
        $resolver->setAllowedTypes('help', ['null', 'string']);
58
        $resolver->setAllowedTypes('help_translation_domain', ['null', 'bool', 'string']);
59
    }
60
61
    public static function getExtendedTypes(): iterable
62
    {
63
        return [
64
            FormType::class,
65
        ];
66
    }
67
}
68