RemoveChild::addElements()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2
Metric Value
dl 0
loc 13
ccs 10
cts 10
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
3
namespace SpeckCatalog\Form;
4
5
use Zend\Form\Form as ZendForm;
6
7
class RemoveChild extends ZendForm
8
{
9 2
    public function __construct()
10
    {
11 2
        parent::__construct();
12 2
        $this->add(array(
13 2
            'name' => 'submit',
14 2
            'type' => 'Zend\Form\Element\Submit',
15
            'attributes' => array(
16 2
                'value' => ' x ',
17 2
            ),
18 2
        ));
19 2
    }
20
21 2
    public function addElements(array $elements)
22
    {
23 2
        foreach ($elements as $key => $val) {
24 2
            $this->add(array(
25 2
                'name' => $key,
26
                'attributes' => array(
27 2
                    'type' => 'hidden',
28 2
                    'value' => $val,
29 2
                ),
30 2
            ));
31 2
        }
32 2
        return $this;
33
    }
34
35 2
    public function addParent(array $elements)
36
    {
37 2
        foreach ($elements as $key => $val) {
38
            $this->add(array(
39
                'name' => 'parent[' . $key . ']',
40
                'attributes' => array(
41
                    'type' => 'hidden',
42
                    'value' => $val,
43
                ),
44
            ));
45 2
        }
46 2
        return $this;
47
    }
48
49 2
    public function addChild(array $elements)
50
    {
51 2
        foreach ($elements as $key => $val) {
52
            $this->add(array(
53
                'name' => 'child[' . $key . ']',
54
                'attributes' => array(
55
                    'type' => 'hidden',
56
                    'value' => $val,
57
                ),
58
            ));
59 2
        }
60 2
        return $this;
61
    }
62
}
63