Passed
Branch ops-updates (277b44)
by Björn
05:09
created

Element::__invoke()   F

Complexity

Conditions 20
Paths 768

Size

Total Lines 38
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 20
eloc 22
c 0
b 0
f 0
nc 768
nop 1
dl 0
loc 38
rs 0.3222

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * BB's Zend Framework 2 Components
4
 * 
5
 * UI Components
6
 *
7
 * @package     [MyApplication]
8
 * @subpackage  BB's Zend Framework 2 Components
9
 * @subpackage  UI Components
10
 * @author      Björn Bartels <[email protected]>
11
 * @link        https://gitlab.bjoernbartels.earth/groups/zf2
12
 * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
13
 * @copyright   copyright (c) 2016 Björn Bartels <[email protected]>
14
 */
15
16
namespace UIComponents\View\Helper\Components;
17
18
/**
19
 *
20
 * render nothing
21
 *
22
 */
23
class Element extends \UIComponents\View\Helper\AbstractHelper 
24
//implements \Zend\ServiceManager\ServiceLocatorAwareInterface
25
{
26
    
27
    /**
28
     * View helper entry point:
29
     * Retrieves helper and optionally sets component options to operate on
30
     *
31
     * @param  array|StdClass $options [optional] component options to operate on
0 ignored issues
show
Bug introduced by
The type UIComponents\View\Helper\Components\StdClass was not found. Did you mean StdClass? If so, make sure to prefix the type with \.
Loading history...
32
     * @return string|self
33
     */
34
    public function __invoke($options = array())
35
    {
36
        if ( is_object($options) && method_exists($options, 'toArray') ) {
37
            $options = $options->toArray();
38
        } else if ( is_object($options) ) {
39
            $options = (array)$options;
40
        }
41
        
42
        if (isset($options['container']) && (null !== $options['container'])) {
43
            $this->setContainer($options['container']);
44
        }
45
    
46
        if (isset($options['tagname']) && (null !== $options['tagname'])) {
47
            $this->setTagname($options['tagname']);
48
        }
49
        if (isset($options['class']) && (null !== $options['class'])) {
50
            $this->setClassnames($options['class']);
51
        }
52
        if (isset($options['classnames']) && (null !== $options['classnames'])) {
53
            $this->setClassnames($options['classnames']);
54
        }
55
56
        if (isset($options['attr']) && (null !== $options['attr'])) {
57
            $this->setAttributes($options['attr']);
58
        }
59
        if (isset($options['attributes']) && (null !== $options['attributes'])) {
60
            $this->setAttributes($options['attributes']);
61
        }
62
63
        if (isset($options['content']) && (null !== $options['content'])) {
64
            $this->setContent($options['content']);
65
        }
66
        if (isset($options['children']) && (null !== $options['children'])) {
67
            $this->setContent($options['children']);
68
        }
69
        
70
        $component = clone $this;
71
        return $component;
72
    }
73
    
74
}