IDealType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 11 1
A getBankList() 0 9 2
1
<?php
2
/*
3
* (c) Wessel Strengholt <[email protected]>
4
*
5
* For the full copyright and license information, please view the LICENSE
6
* file that was distributed with this source code.
7
*/
8
9
namespace Usoft\IDealBundle\Form\Type;
10
11
use Symfony\Component\Form\AbstractType;
12
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
13
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
14
use Symfony\Component\Form\FormBuilderInterface;
15
use Usoft\IDealBundle\Model\Bank;
16
17
/**
18
 * Class IDealType
19
 *
20
 * @author Wessel Strengholt <[email protected]>
21
 */
22
class IDealType extends abstractType
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function buildForm(FormBuilderInterface $builder, array $options)
28
    {
29
        $builder->add(
30
            'banks', ChoiceType::class, array(
31
                'choices' => $this->getBankList($options['data']),
32
                'required'  => true,
33
            )
34
        );
35
36
        $builder->add('save', SubmitType::class, array());
37
    }
38
39
    /**
40
     * @param Bank[] $banks
41
     *
42
     * @return array
43
     */
44
    private function getBankList($banks)
45
    {
46
        $list = array();
47
        foreach ($banks as $bank) {
48
            $list[$bank->getName()] = $bank->getId();
49
        }
50
51
        return $list;
52
    }
53
}
54