Passed
Push — feature/eco-2295/eco-2356-main... ( 8a87d8...4fb803 )
by Aleksey
01:47
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\ChoiceType;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Form\E...on\Core\Type\ChoiceType 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 BillSubForm extends AbstractSubFormType implements SubFormInterface, SubFormProviderNameInterface
20
{
21
    protected const PAYMENT_METHOD = 'bill';
22
    protected const FORM_FIELD_PAYMENT_METHOD = 'paymentMethod';
23
    protected const FORM_FIELD_PAYMENT_METHOD_DATA = 'BILL';
24
25
    /**
26
     * @return string
27
     */
28
    public function getProviderName(): string
29
    {
30
        return CrefoPayConfig::PROVIDER_NAME;
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getName(): string
37
    {
38
        return CrefoPayConfig::CREFO_PAY_PAYMENT_METHOD_BILL;
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function getPropertyPath(): string
45
    {
46
        return CrefoPayConfig::CREFO_PAY_PAYMENT_METHOD_BILL;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getTemplatePath(): string
53
    {
54
        return CrefoPayConfig::PROVIDER_NAME . DIRECTORY_SEPARATOR . static::PAYMENT_METHOD;
55
    }
56
57
    /**
58
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
59
     *
60
     * @return void
61
     */
62
    public function configureOptions(OptionsResolver $resolver): void
63
    {
64
        $resolver->setDefaults([
65
            'data_class' => CrefoPayPaymentTransfer::class,
66
        ])->setRequired(static::OPTIONS_FIELD_NAME);
67
    }
68
69
    /**
70
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
71
     * @param array $options
72
     *
73
     * @return void
74
     */
75
    public function buildForm(FormBuilderInterface $builder, array $options): void
76
    {
77
        $this->addPaymentMethod($builder);
78
    }
79
80
    /**
81
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
82
     *
83
     * @return $this
84
     */
85
    protected function addPaymentMethod(FormBuilderInterface $builder)
86
    {
87
        $builder->add(
88
            static::FORM_FIELD_PAYMENT_METHOD,
89
            ChoiceType::class,
90
            [
91
                'choices' => [static::FORM_FIELD_PAYMENT_METHOD_DATA],
92
                'choices_as_values' => true,
93
                'expanded' => true,
94
            ]
95
        );
96
97
        return $this;
98
    }
99
}
100