Passed
Pull Request — master (#74)
by oleksandr
04:26
created

EWalletSubForm::getTemplatePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Yves\Payone\Form;
9
10
use Generated\Shared\Transfer\PaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentTransfer 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 Generated\Shared\Transfer\PayonePaymentEWalletTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...ePaymentEWalletTransfer 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;
13
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
14
use Symfony\Component\Form\FormBuilderInterface;
15
use Symfony\Component\OptionsResolver\OptionsResolver;
16
17
/**
18
 * @method \SprykerEco\Yves\Payone\PayoneConfig getConfig()
19
 */
20
class EWalletSubForm extends AbstractPayoneSubForm
21
{
22
    /**
23
     * @var string
24
     */
25
    public const PAYMENT_METHOD = 'e_wallet';
26
27
    /**
28
     * @var string
29
     */
30
    public const FIELD_WALLET_TYPE = 'wallettype';
31
32
    /**
33
     * @var string
34
     */
35
    public const OPTION_WALLET_CHOICES = 'wallet_types';
36
37
    /**
38
     * @return string
39
     */
40
    public function getName(): string
41
    {
42
        return PaymentTransfer::PAYONE_E_WALLET;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getPropertyPath(): string
49
    {
50
        return PaymentTransfer::PAYONE_E_WALLET;
51
    }
52
53
    /**
54
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
55
     *
56
     * @return void
57
     */
58
    public function configureOptions(OptionsResolver $resolver): void
59
    {
60
        $resolver->setDefaults([
61
            'data_class' => PayonePaymentEWalletTransfer::class,
62
        ])->setRequired(SubFormInterface::OPTIONS_FIELD_NAME);
63
    }
64
65
    /**
66
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
67
     *
68
     * @return void
69
     */
70
    public function setDefaultOptions(OptionsResolver $resolver): void
71
    {
72
        $this->configureOptions($resolver);
73
    }
74
75
    /**
76
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
77
     * @param array $options
78
     *
79
     * @return void
80
     */
81
    public function buildForm(FormBuilderInterface $builder, array $options): void
82
    {
83
        $this->addWalletType($builder, $options[SubFormInterface::OPTIONS_FIELD_NAME][static::OPTION_WALLET_CHOICES]);
84
    }
85
86
    /**
87
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
88
     * @param array $choices
89
     *
90
     * @return $this
91
     */
92
    protected function addWalletType(FormBuilderInterface $builder, array $choices)
93
    {
94
        $builder->add(
95
            static::FIELD_WALLET_TYPE,
96
            ChoiceType::class,
97
            [
98
                'label' => false,
99
                'required' => true,
100
                'choices' => $choices,
101
            ],
102
        );
103
104
        return $this;
105
    }
106
}
107