RedirectException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 6
c 1
b 0
f 1
dl 0
loc 38
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getPath() 0 3 1
A setPath() 0 3 1
1
<?php
2
3
/**
4
 * Linna Framework.
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2018, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types=1);
11
12
namespace Linna\Router\Exception;
13
14
use Exception;
15
16
/**
17
 * Redirect Exception.
18
 * This class should be used to stop execution when a redirection to another
19
 * route/path is requred. $path in setPath() method, must be a value present
20
 * in at least one Route inside routes collection passed to the Router object.
21
 */
22
class RedirectException extends Exception
23
{
24
    /**
25
     * @var string Path on which to be redirected.
26
     */
27
    private $path = '';
28
29
    /**
30
     * Class Constructor.
31
     *
32
     * @param string $path Path on which to be redirected.
33
     */
34 6
    public function __construct(string $path = '')
35
    {
36 6
        parent::__construct();
37
38 6
        $this->path = $path;
39 6
    }
40
41
    /**
42
     * Set path.
43
     *
44
     * @param string $path Path on which to be redirected.
45
     * @return void
46
     */
47 1
    public function setPath(string $path): void
48
    {
49 1
        $this->path = $path;
50 1
    }
51
52
    /**
53
     * Get path.
54
     *
55
     * @return string Path on which to be redirected.
56
     */
57 3
    public function getPath(): string
58
    {
59 3
        return $this->path;
60
    }
61
}
62