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

CachingEndpointFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getLoggingEndpoint() 0 6 1
getCachingEndpoint() 0 1 ?
1
<?php
2
namespace LunixREST\Server\Router\EndpointFactory;
3
4
use LunixREST\Server\Router\Endpoint\CachingEndpoint;
5
use LunixREST\Server\Router\Endpoint\LoggingEndpoint;
6
use Psr\Cache\CacheItemPoolInterface;
7
use Psr\Log\LoggerInterface;
8
9
/**
10
 * An EndpointFactory that extends LoggingEndpointFactory, using a CachingEndpoint by setting a CachePoolInterface on the Endpoint.
11
 * Class CachingEndpointFactory
12
 * @package LunixREST\Server\Router\EndpointFactory
13
 */
14
abstract class CachingEndpointFactory extends LoggingEndpointFactory
15
{
16
    /**
17
     * @var CacheItemPoolInterface
18
     */
19
    protected $cachePool;
20
21
    /**
22
     * CachingEndpointFactory constructor.
23
     * @param CacheItemPoolInterface $cachePool
24
     * @param LoggerInterface $logger
25
     */
26 1
    public function __construct(CacheItemPoolInterface $cachePool, LoggerInterface $logger)
27
    {
28 1
        $this->cachePool = $cachePool;
29 1
        parent::__construct($logger);
30 1
    }
31
32
    /**
33
     * @param string $name
34
     * @param string $version
35
     * @return LoggingEndpoint
36
     */
37 1
    protected function getLoggingEndpoint(string $name, string $version): LoggingEndpoint
38
    {
39 1
        $endpoint = $this->getCachingEndpoint($name, $version);
40 1
        $endpoint->setCachePool($this->cachePool);
41 1
        return $endpoint;
42
    }
43
44
    /**
45
     * @param string $name
46
     * @param string $version
47
     * @return CachingEndpoint
48
     */
49
    protected abstract function getCachingEndpoint(string $name, string $version): CachingEndpoint;
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
50
}
51