SubscriptionType::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Tahoe\Bundle\MultiTenancyBundle\Form\Type;
4
5
6
use Symfony\Component\Form\AbstractType;
7
use Symfony\Component\Form\FormBuilderInterface;
8
use Symfony\Component\Form\FormEvent;
9
use Symfony\Component\Form\FormEvents;
10
11
class SubscriptionType extends AbstractType
12
{
13
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function buildForm(FormBuilderInterface $builder, array $options)
18
    {
19
        $builder
20
            ->add('first_name', 'text')
21
            ->add('last_name', 'text')
22
        ;
23
        $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) {
24
            $data = $event->getData();
25
            $form = $event->getForm();
26
27
            $credit_card = null;
28
            $expiration_date = null;
29
            if (null !== $data) {
30
                $credit_card = sprintf("%s******%s", $data->first_six, $data->last_four);
31
                $expiration_date = sprintf("%s / %s", $data->month, $data->year);
32
            }
33
            $form
34
                ->add('credit_card_number', 'text', array(
35
                'data' => $credit_card
36
                ))
37
                ->add('expiration', 'text', array(
38
                    "data" => $expiration_date,
39
                    'attr' => array(
40
                        "placeholder" => "mm / yyyy"
41
                    )
42
                ))
43
                ->add('verification_value', 'text', array(
44
                    'label' => 'CVC'
45
                ))
46
            ;
47
        });
48
//            ->add('credit_card_number', 'text')
49
//            ->add('expiration', 'text', array(
50
//                'attr' => array(
51
//                    "placeholder" => "mm / yyyy"
52
//                )
53
//            ))
54
        ;
55
56
    }
57
58
    public function getName()
59
    {
60
        return 'tahoe_multitenancy_subscription';
61
    }
62
}