CollectionOptionsBuilder   A
last analyzed

Complexity

Total Complexity 19

Size/Duplication

Total Lines 169
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 19
lcom 2
cbo 3
dl 0
loc 169
rs 10
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A getBuilderType() 0 4 1
A setAllowAdd() 0 4 1
A getAllowAdd() 0 4 1
A setAllowDelete() 0 4 1
A getAllowDelete() 0 4 1
A setDeleteEmpty() 0 4 1
A getDeleteEmpty() 0 4 1
A setPrototype() 0 9 3
A getPrototype() 0 4 1
A setPrototypeName() 0 9 2
A setEntryType() 0 4 1
A getEntryType() 0 4 1
A removeEntryType() 0 4 1
A setEntryOptions() 0 4 1
A getEntryOptions() 0 4 1
A removeEntryOotions() 0 4 1
1
<?php
2
3
namespace steevanb\SymfonyFormOptionsBuilder\OptionsBuilder;
4
5
use steevanb\SymfonyFormOptionsBuilder\Behavior\ByReferenceTrait;
6
use steevanb\SymfonyFormOptionsBuilder\Behavior\OptionAccessorsTrait;
7
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
8
use Symfony\Component\Form\FormTypeInterface;
9
10
class CollectionOptionsBuilder extends AbstractOptionsBuilder
11
{
12
    use OptionAccessorsTrait;
13
    use ByReferenceTrait;
14
15
    /**
16
     * @return string
17
     */
18
    public static function getBuilderType()
19
    {
20
        return CollectionType::class;
21
    }
22
23
    /**
24
     * @param bool $allow
25
     * @return $this
26
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#allow-add
27
     */
28
    public function setAllowAdd($allow = true)
29
    {
30
        return $this->setOption('allow_add', $allow);
31
    }
32
33
    /**
34
     * @return bool
35
     */
36
    public function getAllowAdd()
37
    {
38
        return $this->getOption('allow_add');
39
    }
40
41
    /**
42
     * @param $allow
43
     * @return $this
44
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#allow-delete
45
     */
46
    public function setAllowDelete($allow = true)
47
    {
48
        return $this->setOption('allow_delete', $allow);
49
    }
50
51
    /**
52
     * @return bool
53
     */
54
    public function getAllowDelete()
55
    {
56
        return $this->getOption('allow_delete');
57
    }
58
59
    /**
60
     * @param bool $delete
61
     * @return $this
62
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#delete-empty
63
     */
64
    public function setDeleteEmpty($delete = true)
65
    {
66
        return $this->setOption('delete_empty', $delete);
67
    }
68
69
    /**
70
     * @return bool
71
     */
72
    public function getDeleteEmpty()
73
    {
74
        return $this->getOption('delete_empty');
75
    }
76
77
    /**
78
     * @param bool $prototype
79
     * @param bool $setAllowAdd
80
     * @return $this
81
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#prototype
82
     */
83
    public function setPrototype($prototype = true, $setAllowAdd = true)
84
    {
85
        $this->setOption('prototype', $prototype);
86
        if ($prototype && $setAllowAdd) {
87
            $this->setAllowAdd();
88
        }
89
90
        return $this;
91
    }
92
93
    /**
94
     * @return bool
95
     */
96
    public function getPrototype()
97
    {
98
        return $this->getOption('prototype');
99
    }
100
101
    /**
102
     * @param string $name
103
     * @param bool $setAllowAdd
104
     * @return $this
105
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#prototype-name
106
     */
107
    public function setPrototypeName($name, $setAllowAdd = true)
108
    {
109
        $this->setOption('prototype_name', $name);
110
        if ($setAllowAdd) {
111
            $this->setPrototype();
112
        }
113
114
        return $this;
115
    }
116
117
    /**
118
     * @param string $type
119
     * @return $this
120
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#entry-type
121
     * @since 2.8
122
     */
123
    public function setEntryType($type)
124
    {
125
        return $this->setOption('entry_type', $type);
126
    }
127
128
    /**
129
     * @return string
130
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#entry-type
131
     * @since 2.8
132
     */
133
    public function getEntryType()
134
    {
135
        return $this->getOption('entry_type');
136
    }
137
138
    /**
139
     * @return $this
140
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#entry-type
141
     * @since 2.8
142
     */
143
    public function removeEntryType()
144
    {
145
        return $this->removeOption('entry_type');
146
    }
147
148
    /**
149
     * @param array $options
150
     * @return $this
151
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#entry-options
152
     * @since 2.8
153
     */
154
    public function setEntryOptions(array $options)
155
    {
156
        return $this->setOption('entry_options', $options);
157
    }
158
159
    /**
160
     * @return array|string
161
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#entry-options
162
     * @since 2.8
163
     */
164
    public function getEntryOptions()
165
    {
166
        return $this->getOption('entry_options');
167
    }
168
169
    /**
170
     * @return $this
171
     * @link http://symfony.com/doc/current/reference/forms/types/collection.html#entry-options
172
     * @since 2.8
173
     */
174
    public function removeEntryOotions()
175
    {
176
        return $this->removeOption('entry_options');
177
    }
178
}
179