Slim4Plugin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A pathFor() 0 3 1
A getCallablesTable() 0 5 1
A baseUrl() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EngineWorks\Templates\Slim;
6
7
use EngineWorks\Templates\Plugin;
8
use Slim\Interfaces\RouteParserInterface;
9
10
class Slim4Plugin implements Plugin
11
{
12
    /**
13
     * @inheritdoc
14
     * @return array{pathFor: string, baseUrl: string}
15
     */
16 1
    public function getCallablesTable(): array
17
    {
18
        return [
19 1
            'pathFor' => 'pathFor',
20
            'baseUrl' => 'baseUrl',
21
        ];
22
    }
23
24
    /** @var RouteParserInterface */
25
    private $router;
26
27
    /** @var string */
28
    private $baseUrl;
29
30 2
    public function __construct(RouteParserInterface $router, string $baseUrl)
31
    {
32 2
        $this->router = $router;
33 2
        $this->baseUrl = $baseUrl;
34
    }
35
36
    /**
37
     * @param string $name
38
     * @param string[] $data
39
     * @param string[] $queryParams
40
     * @return string
41
     */
42 1
    public function pathFor(string $name, array $data = [], array $queryParams = []): string
43
    {
44 1
        return $this->router->urlFor($name, $data, $queryParams);
45
    }
46
47 1
    public function baseUrl(): string
48
    {
49 1
        return $this->baseUrl;
50
    }
51
}
52