Completed
Push — master ( 8431a9...0bccd4 )
by Gabriel
04:28
created

Nip_Form_Renderer_Basic   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 18
c 0
b 0
f 0
ccs 0
cts 10
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderElements() 0 14 4
1
<?php
2
class Nip_Form_Renderer_Basic extends Nip_Form_Renderer_Table
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
3
{
4
    public function renderElements()
5
    {
6
        $elements = $this->getElements();
7
        if ($elements) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $elements of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
8
            foreach ($elements as $element) {
9
                if (!$element->isRendered()) {
10
                    $idRow = $element->getUniqueId();
11
                    $this->setRowAttrib($idRow, 'class', "row " . $idRow);
12
                    $this->addCell($idRow, 1, $element, 'label');
13
                    $this->addCell($idRow, 2, $element, 'value');
14
                }
15
            }
16
        }
17
        return parent::renderElements();
18
    }
19
}
20