Passed
Push — feature/eco-2300/crefopay-cred... ( 4beef5...ee9c93 )
by Aleksey
01:18
created

PrepaidSubForm   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 3 1
A getTemplatePath() 0 3 1
A getPropertyPath() 0 3 1
A configureOptions() 0 5 1
A getProviderName() 0 3 1
A addPaymentMethod() 0 16 1
A getName() 0 3 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Yves\CrefoPay\Form;
9
10
use Generated\Shared\Transfer\CrefoPayPaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\CrefoPayPaymentTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Spryker\Yves\StepEngine\Dependency\Form\AbstractSubFormType;
0 ignored issues
show
Bug introduced by
The type Spryker\Yves\StepEngine\...orm\AbstractSubFormType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface;
0 ignored issues
show
Bug introduced by
The type Spryker\Yves\StepEngine\...y\Form\SubFormInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Spryker\Yves\StepEngine\Dependency\Form\SubFormProviderNameInterface;
0 ignored issues
show
Bug introduced by
The type Spryker\Yves\StepEngine\...rmProviderNameInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use SprykerEco\Shared\CrefoPay\CrefoPayConfig;
15
use Symfony\Component\Form\Extension\Core\Type\RadioType;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Form\E...ion\Core\Type\RadioType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Symfony\Component\Form\FormBuilderInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Form\FormBuilderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Symfony\Component\OptionsResolver\OptionsResolver;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\OptionsResolver\OptionsResolver was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
class PrepaidSubForm extends AbstractSubFormType implements SubFormInterface, SubFormProviderNameInterface
20
{
21
    protected const PAYMENT_METHOD = 'prepaid';
22
    protected const FORM_FIELD_PAYMENT_METHOD = 'paymentMethod';
23
    protected const FORM_FIELD_PAYMENT_METHOD_DATA = 'PREPAID';
24
    protected const FORM_FIELD_PAYMENT_METHOD_CLASSES = 'crefopay-payment-method is_hidden';
25
    protected const FORM_FIELD_ATTRIBUTE_DATA_CREFO_PAY_NAME = 'data-crefopay';
26
    protected const FORM_FIELD_ATTRIBUTE_DATA_CREFO_PAY_VALUE = 'paymentMethod';
27
28
    /**
29
     * @return string
30
     */
31
    public function getProviderName(): string
32
    {
33
        return CrefoPayConfig::PROVIDER_NAME;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getName(): string
40
    {
41
        return CrefoPayConfig::CREFO_PAY_PAYMENT_METHOD_PREPAID;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getPropertyPath(): string
48
    {
49
        return CrefoPayConfig::CREFO_PAY_PAYMENT_METHOD_PREPAID;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getTemplatePath(): string
56
    {
57
        return CrefoPayConfig::PROVIDER_NAME . DIRECTORY_SEPARATOR . static::PAYMENT_METHOD;
58
    }
59
60
    /**
61
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
62
     *
63
     * @return void
64
     */
65
    public function configureOptions(OptionsResolver $resolver): void
66
    {
67
        $resolver->setDefaults([
68
            'data_class' => CrefoPayPaymentTransfer::class,
69
        ])->setRequired(static::OPTIONS_FIELD_NAME);
70
    }
71
72
    /**
73
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
74
     * @param array $options
75
     *
76
     * @return void
77
     */
78
    public function buildForm(FormBuilderInterface $builder, array $options): void
79
    {
80
        $this->addPaymentMethod($builder);
81
    }
82
83
    /**
84
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
85
     *
86
     * @return $this
87
     */
88
    protected function addPaymentMethod(FormBuilderInterface $builder)
89
    {
90
        $builder->add(
91
            static::FORM_FIELD_PAYMENT_METHOD,
92
            RadioType::class,
93
            [
94
                'label' => false,
95
                'value' => static::FORM_FIELD_PAYMENT_METHOD_DATA,
96
                'attr' => [
97
                    'class' => static::FORM_FIELD_PAYMENT_METHOD_CLASSES,
98
                    static::FORM_FIELD_ATTRIBUTE_DATA_CREFO_PAY_NAME => static::FORM_FIELD_ATTRIBUTE_DATA_CREFO_PAY_VALUE,
99
                ],
100
            ]
101
        );
102
103
        return $this;
104
    }
105
}
106