CachingEndpointFactory::getLoggingEndpoint()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
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 LunixREST\Server\Router\EndpointFactory\Exceptions\UnableToCreateEndpointException;
7
use Psr\Cache\CacheItemPoolInterface;
8
use Psr\Log\LoggerInterface;
9
10
/**
11
 * An EndpointFactory that extends LoggingEndpointFactory, using a CachingEndpoint by setting a CachePoolInterface on the Endpoint.
12
 * Class CachingEndpointFactory
13
 * @package LunixREST\Server\Router\EndpointFactory
14
 * @deprecated in favor of injecting the CacheItemPoolInterface manually in EndpointFactories. This adds no additional value.
15
 */
16
abstract class CachingEndpointFactory extends LoggingEndpointFactory
0 ignored issues
show
Deprecated Code introduced by
The class LunixREST\Server\Router\...\LoggingEndpointFactory has been deprecated with message: in favor of injecting the LoggerInterface manually in EndpointFactories. This adds no additional value.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
17
{
18
    /**
19
     * @var CacheItemPoolInterface
20
     */
21
    protected $cachePool;
22
23
    /**
24
     * CachingEndpointFactory constructor.
25
     * @param CacheItemPoolInterface $cachePool
26
     * @param LoggerInterface $logger
27
     */
28 1
    public function __construct(CacheItemPoolInterface $cachePool, LoggerInterface $logger)
29
    {
30 1
        $this->cachePool = $cachePool;
31 1
        parent::__construct($logger);
32 1
    }
33
34
    /**
35
     * @param string $name
36
     * @param string $version
37
     * @return LoggingEndpoint
38
     * @throws UnableToCreateEndpointException
39
     */
40 1
    protected function getLoggingEndpoint(string $name, string $version): LoggingEndpoint
41
    {
42 1
        $endpoint = $this->getCachingEndpoint($name, $version);
43 1
        $endpoint->setCachePool($this->cachePool);
44 1
        return $endpoint;
45
    }
46
47
    /**
48
     * @param string $name
49
     * @param string $version
50
     * @return CachingEndpoint
51
     * @throws UnableToCreateEndpointException
52
     */
53
    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...
54
}
55