| Conditions | 5 |
| Paths | 8 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 10 | public function group($elements = null) { |
||
| 11 | |||
| 12 | if (is_null($this->group)) { |
||
| 13 | $this->group = new Collection(); |
||
| 14 | } |
||
| 15 | |||
| 16 | if (is_null($elements)) { |
||
| 17 | return $this->group; |
||
| 18 | } |
||
| 19 | |||
| 20 | if (is_array($elements)) { |
||
| 21 | foreach ($elements as $fieldName => $fieldValue) { |
||
| 22 | $newField = \FormsFactory::makeField($this->_type, $fieldName, $fieldValue); |
||
|
|
|||
| 23 | $this->group->put($fieldName, $newField); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 48 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: