Completed
Push — master ( 728b33...068584 )
by John
02:38
created

LoggingEndpointFactory::getLoggingEndpoint()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
ccs 0
cts 0
cp 0
nc 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