RouteNotDefined   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 0
cbo 1
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_id() 0 4 1
A format_message() 0 4 1
A __construct() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ICanBoogie\Routing;
13
14
use ICanBoogie\Accessor\AccessorTrait;
15
use ICanBoogie\HTTP\Status;
16
17
/**
18
 * Exception thrown when a route does not exists.
19
 *
20
 * @property-read string $id The identifier of the route.
21
 */
22
class RouteNotDefined extends \Exception implements Exception
23
{
24
	use AccessorTrait;
25
26
	/**
27
	 * @var string
28
	 */
29
	private $id;
30
31
	protected function get_id()
32
	{
33
		return $this->id;
34
	}
35
36
	/**
37
	 * @param string $id Identifier of the route.
38
	 * @param int $code
39
	 * @param \Exception $previous
40
	 */
41
	public function __construct($id, $code = Status::NOT_FOUND, \Exception $previous = null)
42
	{
43
		$this->id = $id;
44
45
		parent::__construct($this->format_message($id), $code, $previous);
46
	}
47
48
	/**
49
	 * Formats exception message.
50
	 *
51
	 * @param string $id
52
	 *
53
	 * @return string
54
	 */
55
	protected function format_message($id)
56
	{
57
		return "The route `$id` is not defined.";
58
	}
59
}
60