Test Setup Failed
Push — master ( 30ba39...772506 )
by Björn
18:37
created

Element::__invoke()   F

Complexity

Conditions 20
Paths 768

Size

Total Lines 39

Duplication

Lines 26
Ratio 66.67 %

Importance

Changes 0
Metric Value
dl 26
loc 39
rs 0.3222
c 0
b 0
f 0
cc 20
nc 768
nop 1

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
32
     * @return string|self
33
     */
34
    public function __invoke($options = array())
35
    {
36 View Code Duplication
        if ( is_object($options) && method_exists($options, 'toArray') ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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 View Code Duplication
        if (isset($options['tagname']) && (null !== $options['tagname'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
            $this->setTagname($options['tagname']);
48
        }
49 View Code Duplication
        if (isset($options['class']) && (null !== $options['class'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
            $this->setClassnames($options['class']);
51
        }
52 View Code Duplication
        if (isset($options['classnames']) && (null !== $options['classnames'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
            $this->setClassnames($options['classnames']);
54
        }
55
56 View Code Duplication
        if (isset($options['attr']) && (null !== $options['attr'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
            $this->setAttributes($options['attr']);
58
        }
59 View Code Duplication
        if (isset($options['attributes']) && (null !== $options['attributes'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
            $this->setAttributes($options['attributes']);
61
        }
62
63 View Code Duplication
        if (isset($options['content']) && (null !== $options['content'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
            $this->setContent($options['content']);
65
        }
66 View Code Duplication
        if (isset($options['children']) && (null !== $options['children'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
            $this->setContent($options['children']);
68
        }
69
        
70
        $component = clone $this;
71
        return $component;
72
    }
73
    
74
}