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

LoggingEndpointFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 35
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getEndpoint() 0 6 1
getLoggingEndpoint() 0 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