FormattedRoute   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 50
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get_url() 0 4 1
A get_absolute_url() 0 4 1
A get_route() 0 4 1
A __toString() 0 4 1
A __construct() 0 5 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
16
/**
17
 * Representation of a formatted route.
18
 *
19
 * @property-read string $url Relative URL.
20
 * @property-read string $absolute_url Absolute URL, absolutized with {@link absolutize_url()}.
21
 * @property-read Route $route The route that was used to format the URL.
22
 */
23
class FormattedRoute
24
{
25
	use AccessorTrait;
26
27
	/**
28
	 * The relative URL created by {@link Route::format()}.
29
	 *
30
	 * @var string
31
	 */
32
	protected $url;
33
34
	protected function get_url()
35
	{
36
		return contextualize((string) $this);
37
	}
38
39
	protected function get_absolute_url()
40
	{
41
		return absolutize_url($this->get_url());
42
	}
43
44
	/**
45
	 * The {@link Route} instance that created this instance.
46
	 *
47
	 * @var Route
48
	 */
49
	protected $route;
50
51
	protected function get_route()
52
	{
53
		return $this->route;
54
	}
55
56
	/**
57
	 * Initialize the {@link $url} and {@link $route} properties.
58
	 *
59
	 * @param string $url
60
	 * @param Route $route
61
	 */
62
	public function __construct($url, Route $route)
63
	{
64
		$this->url = $url;
65
		$this->route = $route;
66
	}
67
68
	public function __toString()
69
	{
70
		return $this->url;
71
	}
72
}
73