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

CachingEndpointFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 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