Collection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 51
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 5 1
A getRoutes() 0 3 1
A get() 0 3 1
A post() 0 3 1
1
<?php
2
namespace Fyuze\Routing;
3
4
class Collection
5
{
6
    /**
7
     * @var array
8
     */
9
    protected $routes = [];
10
11
    /**
12
     * @return array
13
     */
14 6
    public function getRoutes()
15
    {
16 6
        return $this->routes;
17
    }
18
19
    /**
20
     * @param $route
21
     * @param $action
22
     * @param null $name
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $name is correct as it would always require null to be passed?
Loading history...
23
     * @param array $options
24
     * @return Collection
25
     */
26 1
    public function post($route, $name, $action, $options = [])
27
    {
28 1
        return $this->add($route, $name, $action, array_merge(['method' => 'POST'], $options));
29
    }
30
31
    /**
32
     * @param $route
33
     * @param $action
34
     * @param null $name
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $name is correct as it would always require null to be passed?
Loading history...
35
     * @param array $options
36
     * @return Collection
37
     */
38 6
    public function get($route, $name, $action, $options = [])
39
    {
40 6
        return $this->add($route, $name, $action, array_merge(['method' => 'GET'], $options));
41
    }
42
43
    /**
44
     * @param $route
45
     * @param $name
46
     * @param $action
47
     * @param array $options
48
     * @return $this
49
     */
50 6
    protected function add($route, $name, $action, $options = [])
51
    {
52 6
        $this->routes[] = new Route($route, $name, $action, $options);
0 ignored issues
show
Unused Code introduced by
The call to Fyuze\Routing\Route::__construct() has too many arguments starting with $options. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
        $this->routes[] = /** @scrutinizer ignore-call */ new Route($route, $name, $action, $options);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
53
54 6
        return $this;
55
    }
56
}
57