CurrencyType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B buildForm() 0 27 1
A getName() 0 4 1
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