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

PrePaymentForm   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 16
dl 0
loc 74
rs 10
c 2
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addLabel() 0 13 1
A buildForm() 0 3 1
A getPropertyPath() 0 3 1
A getName() 0 3 1
A configureOptions() 0 5 1
A setDefaultOptions() 0 3 1
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\PayonePaymentTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PayonePaymentTransfer 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\HiddenType;
14
use Symfony\Component\Form\FormBuilderInterface;
15
use Symfony\Component\OptionsResolver\OptionsResolver;
16
17
/**
18
 * @method \SprykerEco\Yves\Payone\PayoneConfig getConfig()
19
 */
20
class PrePaymentForm extends AbstractPayoneSubForm
21
{
22
    /**
23
     * @var string
24
     */
25
    public const PAYMENT_METHOD = 'prepayment';
26
27
    /**
28
     * @return string
29
     */
30
    public function getName(): string
31
    {
32
        return PaymentTransfer::PAYONE_PRE_PAYMENT;
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getPropertyPath(): string
39
    {
40
        return PaymentTransfer::PAYONE_PRE_PAYMENT;
41
    }
42
43
    /**
44
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
45
     *
46
     * @return void
47
     */
48
    public function configureOptions(OptionsResolver $resolver): void
49
    {
50
        $resolver->setDefaults([
51
            'data_class' => PayonePaymentTransfer::class,
52
        ])->setRequired(SubFormInterface::OPTIONS_FIELD_NAME);
53
    }
54
55
    /**
56
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
57
     *
58
     * @return void
59
     */
60
    public function setDefaultOptions(OptionsResolver $resolver): void
61
    {
62
        $this->configureOptions($resolver);
63
    }
64
65
    /**
66
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
67
     * @param array $options
68
     *
69
     * @return void
70
     */
71
    public function buildForm(FormBuilderInterface $builder, array $options): void
72
    {
73
        $this->addLabel($builder);
74
    }
75
76
    /**
77
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
78
     *
79
     * @return $this
80
     */
81
    protected function addLabel(FormBuilderInterface $builder)
82
    {
83
        $builder->add(
84
            static::FIELD_PAYMENT_METHOD,
85
            HiddenType::class,
86
            [
87
                'label' => false,
88
                'required' => false,
89
                'data' => [],
90
            ],
91
        );
92
93
        return $this;
94
    }
95
}
96