Passed
Pull Request — master (#2755)
by Rafael
03:55
created

BeforeReplaceVariableInCachedUrlEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
dl 0
loc 51
ccs 8
cts 16
cp 0.5
rs 10
c 2
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hasRouting() 0 3 1
A __construct() 0 4 1
A replaceUri() 0 3 1
A getUri() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
namespace ApacheSolrForTypo3\Solr\Event\Routing;
18
19
use Psr\Http\Message\UriInterface;
20
21
/**
22
 * This event will triggered before start to replace placeholder inside of cached URLs
23
 *
24
 * @author Lars Tode <[email protected]>
25
 */
26
class BeforeReplaceVariableInCachedUrlEvent
27
{
28
    /**
29
     * @var UriInterface
30
     */
31
    protected $uri;
32
33
    /**
34
     * Routing is enabled
35
     *
36
     * @var bool
37
     */
38
    protected $routing = false;
39
40
    /**
41
     * BeforeReplaceVariableInCachedUrlEvent constructor.
42
     * @param UriInterface $uri
43
     * @param bool $routing
44
     */
45 35
    public function __construct(UriInterface $uri, bool $routing = false)
46
    {
47 35
        $this->uri = $uri;
48 35
        $this->routing = $routing;
49 35
    }
50
51
    /**
52
     * Returns the URI
53
     *
54
     * @return UriInterface
55
     */
56 35
    public function getUri(): UriInterface
57
    {
58 35
        return $this->uri;
59
    }
60
61
    /**
62
     * Replace the URI object
63
     *
64
     * @param UriInterface $uri
65
     */
66
    public function replaceUri(UriInterface  $uri)
67
    {
68
        $this->uri = $uri;
69
    }
70
71
    /**
72
     * @return bool
73
     */
74 35
    public function hasRouting(): bool
75
    {
76 35
        return $this->routing;
77
    }
78
}
79