Completed
Push — master ( 0a059e...292010 )
by John
02:21
created

LoggingEndpointFactory::getEndpoint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
namespace LunixREST\Server\Router\EndpointFactory;
3
4
use LunixREST\Server\Router\Endpoint\Endpoint;
5
use LunixREST\Server\Router\Endpoint\LoggingEndpoint;
6
use Psr\Log\LoggerInterface;
7
8
/**
9
 * An EndpointFactory implementation that sets the LoggerInterface on LoggingEndpoints.
10
 * Class LoggingEndpointFactory
11
 * @package LunixREST\Server\Router\EndpointFactory
12
 */
13
abstract class LoggingEndpointFactory implements EndpointFactory
14
{
15
    /**
16
     * @var LoggerInterface
17
     */
18
    protected $logger;
19
20
    /**
21
     * LoggingEndpointFactory constructor.
22
     * @param LoggerInterface $logger
23
     */
24 2
    public function __construct(LoggerInterface $logger)
25
    {
26 2
        $this->logger = $logger;
27 2
    }
28
29
    /**
30
     * @param string $name
31
     * @param string $version
32
     * @return Endpoint
33
     */
34 2
    public function getEndpoint(string $name, string $version): Endpoint
35
    {
36 2
        $endpoint = $this->getLoggingEndpoint($name, $version);
37 2
        $endpoint->setLogger($this->logger);
38 2
        return $endpoint;
39
    }
40
41
    /**
42
     * @param string $name
43
     * @param string $version
44
     * @return LoggingEndpoint
45
     */
46
    protected abstract function getLoggingEndpoint(string $name, string $version): LoggingEndpoint;
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
47
}
48