RedirectException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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