Completed
Branch 2.0.1 (3659a8)
by Serhii
03:59
created

Robot   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 79
Duplicated Lines 25.32 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 20
loc 79
rs 10
wmc 11
lcom 0
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getHomepage() 0 4 1
A isSearchEngine() 0 4 1
A getOwner() 0 4 1
A setHomepage() 0 4 1
A setOwner() 0 4 1
A setSearchEngine() 0 4 1
B __construct() 20 20 5

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
 * @author Sergey Nehaenko <[email protected]>
4
 * @license GPL
5
 * @copyright Sergey Nehaenko &copy 2016
6
 * @version 2.0
7
 * @project browser-detector
8
 */
9
10
namespace EndorphinStudio\Detector;
11
12
13
class Robot extends Data
14
{
15
    /**
16
     * @return string
17
     */
18
    public function getHomepage()
19
    {
20
        return $this->Homepage;
21
    }
22
23
    /**
24
     * @return boolean
25
     */
26
    public function isSearchEngine()
27
    {
28
        return $this->SearchEngine;
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getOwner()
35
    {
36
        return $this->Owner;
37
    }
38
39
    /**
40
     * @param string $Homepage
41
     */
42
    public function setHomepage($Homepage)
43
    {
44
        $this->Homepage = $Homepage;
45
    }
46
47
    /**
48
     * @param string $Owner
49
     */
50
    public function setOwner($Owner)
51
    {
52
        $this->Owner = $Owner;
53
    }
54
55
    /**
56
     * @param boolean $isSearchEngine
57
     */
58
    public function setSearchEngine($isSearchEngine)
59
    {
60
        $this->SearchEngine = $isSearchEngine;
61
    }
62
    /** @var string Crawler homepage */
63
    private $Homepage;
64
65
    /** @var boolean Search Engine */
66
    private $SearchEngine;
67
68
    /** @var string Crawler Owner */
69
    private $Owner;
70
71 View Code Duplication
    public function __construct(\SimpleXMLElement $xmlData)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
72
    {
73
        parent::__construct($xmlData);
74
75
        if($xmlData !== null)
76
        {
77
            foreach ($xmlData->children() as $child)
78
            {
79
                switch ($child->getName())
80
                {
81
                    case 'url':
82
                        $this->Homepage = $child->__toString();
83
                        break;
84
                    case 'owner':
85
                        $this->Owner = $child->__toString();
86
                        break;
87
                }
88
            }
89
        }
90
    }
91
}
92