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

getElementAttribs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
class Nip_Form_Renderer_DisplayGroup
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...
4
{
5
   
6
    /**
7
     * @var Nip_Form_DisplayGroup
8
     */
9
    protected $_group;
10
11
12
    /**
13
     * @return Nip_Form_Renderer_DisplayGroup
14
     */
15
    public function setGroup(Nip_Form_DisplayGroup $group)
16
    {
17
        $this->_group = $group;
18
        return $this;
19
    }
20
21
    /**
22
     * @return Nip_Form_Renderer_DisplayGroup|null
23
     */
24
    public function getGroup()
25
    {
26
        return $this->_group;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->_group returns the type Nip_Form_DisplayGroup which is incompatible with the documented return type Nip_Form_Renderer_DisplayGroup|null.
Loading history...
27
    }
28
    
29
    public function render()
30
    {
31
        $return = '<fieldset' . $this->renderAttributes() . '>';
32
        $return .= '<legend>' . $this->getGroup()->getLegend() . '</legend>';
0 ignored issues
show
Bug introduced by
The method getLegend() does not exist on Nip_Form_Renderer_DisplayGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $return .= '<legend>' . $this->getGroup()->/** @scrutinizer ignore-call */ getLegend() . '</legend>';

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
34
        $renderer = clone $this->getGroup()->getForm()->getRenderer();
0 ignored issues
show
Bug introduced by
The method getForm() does not exist on Nip_Form_Renderer_DisplayGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $renderer = clone $this->getGroup()->/** @scrutinizer ignore-call */ getForm()->getRenderer();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
        $renderer->setElements($this->getGroup()->toArray());
0 ignored issues
show
Bug introduced by
The method toArray() does not exist on Nip_Form_Renderer_DisplayGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $renderer->setElements($this->getGroup()->/** @scrutinizer ignore-call */ toArray());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
        $return .= $renderer->renderElements();
37
        $return .= '</fieldset>';
38
        return $return;
39
    }
40
    
41
    public function renderAttributes($overrides = array())
42
    {
43
        $attribs = $this->getGroup()->getAttribs();
0 ignored issues
show
Bug introduced by
The method getAttribs() does not exist on Nip_Form_Renderer_DisplayGroup. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $attribs = $this->getGroup()->/** @scrutinizer ignore-call */ getAttribs();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        $elementAttribs = $this->getElementAttribs();
45
        $return = '';
46
        foreach ($attribs as $name => $value) {
47
            if (in_array($name, $elementAttribs)) {
48
                if (in_array($name, array_keys($overrides))) {
49
                    $value = $overrides[$name];
50
                }
51
                $return .= ' ' . $name . '="' . $value . '"';
52
            }
53
        }
54
        return $return;
55
    }
56
57
    public function getElementAttribs()
58
    {
59
        return array('id', 'style', 'class');
60
    }
61
}
62