Match::getSegments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * @package    Fuel\Routing
4
 * @version    2.0
5
 * @author     Fuel Development Team
6
 * @license    MIT License
7
 * @copyright  2010 - 2015 Fuel Development Team
8
 * @link       http://fuelphp.com
9
 */
10
11
namespace Fuel\Routing;
12
13
class Match
14
{
15
	public $uri;
16
	public $name;
17
	public $action;
18
	public $method;
19
	public $translation;
20
	public $parameters;
21
	public $response;
22
	public $namespace;
23
	public $controller;
24
25
	public function __construct(Route $route = null, $method, $uri, $translation, array $parameters = array(), $name = null)
26
	{
27
		$this->uri = $uri;
28
		$this->name = $name;
29
		$this->route = $route;
0 ignored issues
show
Bug introduced by
The property route does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
30
		$this->method = $method;
31
		$this->translation = $translation;
32
		$this->parameters = $parameters;
33
	}
34
35
	public function setNamespace($namespace)
36
	{
37
		$this->namespace = trim($namespace, '\\').'\\';
38
39
		return $this;
40
	}
41
42
	public function setController($controller)
43
	{
44
		$this->controller = trim($controller, '\\');
45
46
		return $this;
47
	}
48
49
	public function setAction($action)
50
	{
51
		$this->action = $action;
52
	}
53
54
	public function getSegments()
55
	{
56
		return explode('/', $this->uri);
57
	}
58
}
59