Completed
Push — master ( 728b33...068584 )
by John
02:38
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
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 10

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\Endpoint;
3
4
use Psr\Log\LoggerAwareInterface;
5
use Psr\Log\LoggerInterface;
6
7
/**
8
 * An EndpointFactory that assumes all created endpoints are LoggingEndpoints
9
 * Class LoggingEndpointFactory
10
 * @package LunixREST\Endpoint
11
 */
12
abstract class LoggingEndpointFactory implements EndpointFactory, LoggerAwareInterface
13
{
14
    /**
15
     * @var LoggerInterface
16
     */
17
    protected $logger;
18
19
    /**
20
     * LoggingEndpointFactory constructor.
21
     * @param LoggerInterface $logger
22
     */
23 1
    public function __construct(LoggerInterface $logger)
24
    {
25 1
        $this->logger = $logger;
26 1
    }
27
28
    /**
29
     * @param string $name
30
     * @param string $version
31
     * @return Endpoint
32
     */
33 1
    public function getEndpoint(string $name, string $version): Endpoint
34
    {
35 1
        $endpoint = $this->getLoggingEndpoint($name, $version);
36 1
        $endpoint->setLogger($this->logger);
37 1
        return $endpoint;
38
    }
39
40
    /**
41
     * @param string $name
42
     * @param string $version
43
     * @return LoggingEndpoint
44
     */
45
    public 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...
46
}
47