MoneyFieldset::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 1

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 21
ccs 16
cts 16
cp 1
rs 9.3142
cc 1
eloc 13
nc 1
nop 0
crap 1
1
<?php
2
3
namespace ZFBrasil\DoctrineMoneyModule\Form;
4
5
use Zend\Form\Element\Number;
6
use Zend\Form\Fieldset;
7
use Zend\InputFilter\InputFilterProviderInterface;
8
use ZFBrasil\DoctrineMoneyModule\Form\Element\CurrencySelect;
9
use ZFBrasil\DoctrineMoneyModule\InputFilter\MoneyInputFilter;
10
11
/**
12
 * Money form element that will make it very easy to work with money and currencies.
13
 *
14
 * @author Fábio Carneiro <[email protected]>
15
 * @license MIT
16
 */
17
class MoneyFieldset extends Fieldset implements InputFilterProviderInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 3
    public function init()
23
    {
24 3
        $this->add([
25 3
            'type' => Number::class,
26 3
            'name' => 'amount',
27
            'options' => [
28 3
                'label' => 'Amount',
29 3
            ],
30
            'attributes' => [
31 3
                'step' => '0.01',
32 3
            ],
33 3
        ]);
34
35 3
        $this->add([
36 3
            'type' => CurrencySelect::class,
37 3
            'name' => 'currency',
38
            'options' => [
39 3
                'label' => 'Currency',
40 3
            ],
41 3
        ]);
42 3
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 3
    public function getInputFilterSpecification()
48
    {
49 3
        return ['type' => MoneyInputFilter::class];
50
    }
51
}
52