CurrencyType::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @author Rafał Muszyński <[email protected]>
5
 * @copyright 2015 Sourcefabric z.ú.
6
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
7
 */
8
namespace Newscoop\PaywallBundle\Form\Type;
9
10
use Symfony\Component\Form\AbstractType;
11
use Symfony\Component\Form\FormBuilderInterface;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
/**
15
 * Currency form type.
16
 */
17
class CurrencyType extends AbstractType
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function buildForm(FormBuilderInterface $builder, array $options)
23
    {
24
        $builder
25
            ->add('code', 'currency', array(
26
                'label' => 'paywall.label.code',
27
                'required' => true,
28
                'constraints' => array(
29
                    new Assert\NotBlank(),
30
                ),
31
            ))
32
            ->add('isActive', 'checkbox', array(
33
                'label' => 'paywall.label.isactive',
34
                'required' => false,
35
            ))
36
            ->add('exchangeRate', 'number', array(
37
                'label' => 'paywall.label.exchangerate',
38
                'precision' => 5,
39
                'constraints' => array(
40
                    new Assert\NotBlank(),
41
                    new Assert\Type(array('type' => 'numeric')),
42
                    new Assert\Range(array(
43
                        'min' => '0.00001',
44
                        'max' => '99999.99999',
45
                    )),
46
                ),
47
            ));
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getName()
54
    {
55
        return 'paywall_currency';
56
    }
57
}
58