Conditions | 5 |
Paths | 8 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5.0113 |
Changes | 0 |
1 | <?php |
||
22 | 1 | public function addDisplayGroup(array $elements, $name) |
|
23 | { |
||
24 | 1 | $group = $this->newDisplayGroup(); |
|
25 | 1 | foreach ($elements as $element) { |
|
26 | 1 | if (isset($this->_elements[$element])) { |
|
|
|||
27 | 1 | $add = $this->getElement($element); |
|
28 | 1 | if (null !== $add) { |
|
29 | 1 | $group->addElement($add); |
|
30 | } |
||
31 | } |
||
32 | } |
||
33 | 1 | if (empty($group)) { |
|
34 | trigger_error('No valid elements specified for display group'); |
||
35 | } |
||
36 | |||
37 | 1 | $name = (string)$name; |
|
38 | 1 | $group->setLegend($name); |
|
39 | |||
40 | 1 | $this->_displayGroups[$name] = $group; |
|
41 | |||
42 | 1 | return $this; |
|
43 | } |
||
44 | |||
77 |
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: