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

BillSubForm::buildForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\HiddenType;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Form\E...on\Core\Type\HiddenType 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\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...
17
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...
18
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...
19
20
class BillSubForm extends AbstractSubFormType implements SubFormInterface, SubFormProviderNameInterface
21
{
22
    protected const PAYMENT_METHOD = 'bill';
23
    protected const FORM_FIELD_PAYMENT_METHOD = 'paymentMethod';
24
    protected const FORM_FIELD_PAYMENT_METHOD_DATA = 'BILL';
25
    protected const FORM_FIELD_PAYMENT_METHOD_CLASSES = 'crefopay-payment-method is_hidden';
26
    protected const FORM_FIELD_ATTRIBUTE_DATA_CREFO_PAY_NAME = 'data-crefopay';
27
    protected const FORM_FIELD_ATTRIBUTE_DATA_CREFO_PAY_VALUE = 'paymentMethod';
28
29
    /**
30
     * @return string
31
     */
32
    public function getProviderName(): string
33
    {
34
        return CrefoPayConfig::PROVIDER_NAME;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getName(): string
41
    {
42
        return CrefoPayConfig::CREFO_PAY_PAYMENT_METHOD_BILL;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getPropertyPath(): string
49
    {
50
        return CrefoPayConfig::CREFO_PAY_PAYMENT_METHOD_BILL;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getTemplatePath(): string
57
    {
58
        return CrefoPayConfig::PROVIDER_NAME . DIRECTORY_SEPARATOR . static::PAYMENT_METHOD;
59
    }
60
61
    /**
62
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
63
     *
64
     * @return void
65
     */
66
    public function configureOptions(OptionsResolver $resolver): void
67
    {
68
        $resolver->setDefaults([
69
            'data_class' => CrefoPayPaymentTransfer::class,
70
        ])->setRequired(static::OPTIONS_FIELD_NAME);
71
    }
72
73
    /**
74
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
75
     * @param array $options
76
     *
77
     * @return void
78
     */
79
    public function buildForm(FormBuilderInterface $builder, array $options): void
80
    {
81
        $this->addPaymentMethod($builder);
82
    }
83
84
    /**
85
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
86
     *
87
     * @return $this
88
     */
89
    protected function addPaymentMethod(FormBuilderInterface $builder)
90
    {
91
        $builder->add(
92
            static::FORM_FIELD_PAYMENT_METHOD,
93
            RadioType::class,
94
            [
95
                'label' => false,
96
                'value' => static::FORM_FIELD_PAYMENT_METHOD_DATA,
97
                'attr' => [
98
                    'class' => static::FORM_FIELD_PAYMENT_METHOD_CLASSES,
99
                    static::FORM_FIELD_ATTRIBUTE_DATA_CREFO_PAY_NAME => static::FORM_FIELD_ATTRIBUTE_DATA_CREFO_PAY_VALUE,
100
                ],
101
            ]
102
        );
103
104
        return $this;
105
    }
106
}
107