LoggingEndpointFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
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 37
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 LunixREST\Server\Router\EndpointFactory\Exceptions\UnableToCreateEndpointException;
7
use Psr\Log\LoggerInterface;
8
9
/**
10
 * An EndpointFactory implementation that sets the LoggerInterface on LoggingEndpoints.
11
 * Class LoggingEndpointFactory
12
 * @package LunixREST\Server\Router\EndpointFactory
13
 * @deprecated in favor of injecting the LoggerInterface manually in EndpointFactories. This adds no additional value.
14
 */
15
abstract class LoggingEndpointFactory implements EndpointFactory
16
{
17
    /**
18
     * @var LoggerInterface
19
     */
20
    protected $logger;
21
22
    /**
23
     * LoggingEndpointFactory constructor.
24
     * @param LoggerInterface $logger
25
     */
26 2
    public function __construct(LoggerInterface $logger)
27
    {
28 2
        $this->logger = $logger;
29 2
    }
30
31
    /**
32
     * @param string $name
33
     * @param string $version
34
     * @return Endpoint
35
     * @throws UnableToCreateEndpointException
36
     */
37 2
    public function getEndpoint(string $name, string $version): Endpoint
38
    {
39 2
        $endpoint = $this->getLoggingEndpoint($name, $version);
40 2
        $endpoint->setLogger($this->logger);
41 2
        return $endpoint;
42
    }
43
44
    /**
45
     * @param string $name
46
     * @param string $version
47
     * @return LoggingEndpoint
48
     * @throws UnableToCreateEndpointException
49
     */
50
    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...
51
}
52