Passed
Push — feature/paypal-express ( ec9040...c08f5f )
by Volodymyr
06:46
created

CheckoutShipmentForm   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 56
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A configureOptions() 0 3 1
A getBlockPrefix() 0 3 1
A buildForm() 0 5 1
A addIdShipmentMethod() 0 13 1
1
<?php
2
3
namespace SprykerEco\Yves\Braintree\Form;
4
5
use Generated\Shared\Transfer\QuoteTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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...
6
use Spryker\Yves\Kernel\Form\AbstractType;
7
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
8
use Symfony\Component\Form\FormBuilderInterface;
9
use Symfony\Component\OptionsResolver\OptionsResolver;
10
use Symfony\Component\Validator\Constraints\NotBlank;
11
12
class CheckoutShipmentForm extends AbstractType
13
{
14
    public const FIELD_ID_SHIPMENT_METHOD = 'idShipmentMethod';
15
    public const OPTION_SHIPMENT_METHODS = 'shipmentMethods';
16
17
    public const SHIPMENT_PROPERTY_PATH = 'shipment';
18
    public const SHIPMENT_SELECTION = 'shipmentSelection';
19
    public const SHIPMENT_SELECTION_PROPERTY_PATH = self::SHIPMENT_PROPERTY_PATH . '.' . self::SHIPMENT_SELECTION;
20
21
    protected const VALIDATION_NOT_BLANK_MESSAGE = 'validation.not_blank';
22
23
    public const FORM_NAME = 'checkoutShipmentForm';
24
25
    /**
26
     * @return string
27
     */
28
    public function getBlockPrefix()
29
    {
30
        return static::FORM_NAME;
31
    }
32
33
    public function buildForm(FormBuilderInterface $builder, array $options)
34
    {
35
        $builder->setAction('/test');
36
37
        $this->addIdShipmentMethod($builder, $options);
38
    }
39
40
    /**
41
     * @param FormBuilderInterface $builder
42
     * @param array $options
43
     *
44
     * @return void
45
     */
46
    protected function addIdShipmentMethod(FormBuilderInterface $builder, array $options): void
47
    {
48
        $builder->add(self::FIELD_ID_SHIPMENT_METHOD, ChoiceType::class, [
49
            'choices' => $options[self::OPTION_SHIPMENT_METHODS],
50
            'expanded' => true,
51
            'multiple' => false,
52
            'required' => true,
53
            'property_path' => static::SHIPMENT_SELECTION_PROPERTY_PATH,
54
            'placeholder' => false,
55
            'constraints' => [
56
                new NotBlank(),
57
            ],
58
            'label' => false,
59
        ]);
60
    }
61
62
    /**
63
     * @param OptionsResolver $resolver
64
     */
65
    public function configureOptions(OptionsResolver $resolver)
66
    {
67
        $resolver->setRequired('shipmentMethods');
68
    }
69
}