GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 2f12c3...e53ef5 )
by Hilari
02:46
created

CacheFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 3
dl 0
loc 47
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A arrayCache() 0 4 1
A decorateForTesting() 0 4 1
A redisFromParams() 0 8 1
A redisCache() 0 4 1
1
<?php
2
3
namespace Cmp\Cache\Application;
4
5
use Cmp\Cache\Domain\Cache;
6
use Cmp\Cache\Infrastructure\ArrayCache;
7
use Cmp\Cache\Infrastructure\RedisCache;
8
use Redis;
9
10
/**
11
 * Class CacheFactory
12
 *
13
 * @package Cmp\Cache\Application
14
 */
15
class CacheFactory
16
{
17
    /**
18
     * @return ArrayCache
19
     */
20
    public static function arrayCache()
21
    {
22
        return new ArrayCache();
23
    }
24
25
    /**
26
     * @param       $host
27
     * @param       $port
28
     * @param int   $db
29
     * @param float $timeOut
30
     *
31
     * @return RedisCache
32
     */
33
    public static function redisFromParams($host, $port = 6379, $db = 0, $timeOut = 0.0)
34
    {
35
        $redis = new Redis();
36
        $redis->pconnect($host, $port, $timeOut);
37
        $redis->select($db);
38
39
        return self::redisCache($redis);
40
    }
41
42
    /**
43
     * @param Redis $redis
44
     *
45
     * @return RedisCache
46
     */
47
    public static function redisCache(Redis $redis)
48
    {
49
        return new RedisCache($redis);
50
    }
51
52
    /**
53
     * @param Cache $cache
54
     *
55
     * @return TestCacheDecorator
56
     */
57
    public static function decorateForTesting(Cache $cache)
58
    {
59
        return new TestCacheDecorator($cache);
60
    }
61
}
62