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

Element   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 52
Duplicated Lines 50 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 20
lcom 0
cbo 1
dl 26
loc 52
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
F __invoke() 26 39 20

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}