Test Failed
Push — master ( 3eb0e4...9196b6 )
by Ivan
02:13
created

Url   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 29
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getUri() 4 4 1
A getUrl() 4 4 1

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
declare(strict_types = 1);
4
5
namespace Everlution\Navigation\Item;
6
7
use Everlution\Navigation\Item;
8
use Everlution\Navigation\NavigationItem;
9
use Everlution\Navigation\Uri\SimpleUri;
10
use Everlution\Navigation\Uri\Uri;
11
use Everlution\Navigation\Voter\Exact\ExactMatch;
12
13
/**
14
 * Class Url.
15
 * @author Ivan Barlog <[email protected]>
16
 */
17 View Code Duplication
class Url extends NavigationItem
0 ignored issues
show
Duplication introduced by
This class 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...
18
{
19
    /** @var SimpleUri */
20
    private $uri;
21
22
    public function __construct(string $label, string $url, Item $parent = null, array $children = [])
23
    {
24
        parent::__construct($label, $parent, $children);
25
26
        $this->uri = new SimpleUri($url);
27
        $this->addMatch(new ExactMatch($url));
28
    }
29
30
    /**
31
     * @return SimpleUri|Uri
32
     */
33
    public function getUri(): Uri
34
    {
35
        return $this->uri;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getUrl(): string
42
    {
43
        return $this->uri->getUri();
44
    }
45
}
46