Completed
Push — master ( a42644...fb7144 )
by Oleksandr
10s
created

PrePaymentForm::configureOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 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;
11
use Generated\Shared\Transfer\PayonePaymentTransfer;
12
use Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface;
13
use SprykerEco\Shared\Payone\PayoneConstants;
14
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
15
use Symfony\Component\Form\FormBuilderInterface;
16
use Symfony\Component\OptionsResolver\OptionsResolver;
17
18 View Code Duplication
class PrePaymentForm extends AbstractPayoneSubForm
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
    const PAYMENT_METHOD = 'prepayment';
21
22
    /**
23
     * @return string
24
     */
25
    public function getName()
26
    {
27
        return PaymentTransfer::PAYONE_PRE_PAYMENT;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getPropertyPath()
34
    {
35
        return PaymentTransfer::PAYONE_PRE_PAYMENT;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getTemplatePath()
42
    {
43
        return PayoneConstants::PROVIDER_NAME . '/' . self::PAYMENT_METHOD;
44
    }
45
46
    /**
47
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
48
     *
49
     * @return void
50
     */
51
    public function configureOptions(OptionsResolver $resolver)
52
    {
53
        $resolver->setDefaults([
54
            'data_class' => PayonePaymentTransfer::class,
55
        ])->setRequired(SubFormInterface::OPTIONS_FIELD_NAME);
56
    }
57
58
    /**
59
     * @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver
60
     *
61
     * @return void
62
     */
63
    public function setDefaultOptions(OptionsResolver $resolver)
64
    {
65
        $this->configureOptions($resolver);
66
    }
67
68
    /**
69
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
70
     * @param array $options
71
     *
72
     * @return void
73
     */
74
    public function buildForm(FormBuilderInterface $builder, array $options)
75
    {
76
        $this->addLabel($builder);
77
    }
78
79
    /**
80
     * @param \Symfony\Component\Form\FormBuilderInterface $builder
81
     *
82
     * @return $this
83
     */
84
    protected function addLabel(FormBuilderInterface $builder)
85
    {
86
        $builder->add(
87
            self::FIELD_PAYMENT_METHOD,
88
            HiddenType::class,
89
            [
90
                'label' => false,
91
                'required' => false,
92
                'data' => [],
93
            ]
94
        );
95
96
        return $this;
97
    }
98
}
99