Code Duplication    Length = 29-42 lines in 2 locations

src/Item/Route.php 1 location

@@ 17-58 (lines=42) @@
14
 * Class Route.
15
 * @author Ivan Barlog <[email protected]>
16
 */
17
class Route extends NavigationItem
18
{
19
    /** @var RouteUri */
20
    private $uri;
21
22
    public function __construct(
23
        string $label,
24
        string $route,
25
        array $parameters = [],
26
        Item $parent = null,
27
        array $children = []
28
    ) {
29
        parent::__construct($label, $parent, $children);
30
31
        $this->uri = new RouteUri($route, $parameters);
32
        $this->addMatch(new ExactMatch($route));
33
    }
34
35
    /**
36
     * @return RouteUri|Uri
37
     */
38
    public function getUri(): Uri
39
    {
40
        return $this->uri;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getRoute(): string
47
    {
48
        return $this->uri->getRoute();
49
    }
50
51
    /**
52
     * @return array
53
     */
54
    public function getRouteParameters(): array
55
    {
56
        return $this->uri->getParameters();
57
    }
58
}
59

src/Item/Url.php 1 location

@@ 17-45 (lines=29) @@
14
 * Class Url.
15
 * @author Ivan Barlog <[email protected]>
16
 */
17
class Url extends NavigationItem
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