Passed
Push — master ( 860a21...141758 )
by Mike
03:50
created

AbstractControllerProvider::addController()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\Controller\Business\Model\Route;
6
7
8
use DataProvider\RouteDataProvider;
9
use Xervice\Web\Business\Dependency\Plugin\AbstractWebProviderPlugin;
10
11
abstract class AbstractControllerProvider extends AbstractWebProviderPlugin
12
{
13 6
    public function addController(
14
        string $path,
15
        string $controller,
16
        string $action,
17
        array $methods
18
    ): RouteDataProvider
19
    {
20 6
        $route = new RouteDataProvider();
21
22
        $route
23 6
            ->setName($controller . '::' . $action)
24 6
            ->setPath($path)
25 6
            ->setDefaults(
26
                [
27 6
                    '_controller' => $controller,
28 6
                    '_action' => $action
29
                ]
30
            )
31 6
            ->setMethods(
32 6
                $methods
33
            );
34
35 6
        return $route;
36
    }
37
}