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

PrePaymentForm   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 81
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 3
dl 81
loc 81
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 4 4 1
A getPropertyPath() 4 4 1
A getTemplatePath() 4 4 1
A configureOptions() 6 6 1
A setDefaultOptions() 4 4 1
A buildForm() 4 4 1
A addLabel() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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