TestableFileCache   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 35
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A skipTime() 0 3 1
A __construct() 0 5 1
A getTime() 0 3 1
A getCachePath() 0 3 1
1
<?php
2
3
namespace Kodus\Cache\Test;
4
5
use Kodus\Cache\FileCache;
6
7
/**
8
 * File cache extension for testing - makes time stand still and allows us to time-travel ;-)
9
 */
10
class TestableFileCache extends FileCache
11
{
12
    /**
13
     * @var int
14
     */
15
    protected $time_frozen;
16
17
    public function __construct($cache_path, $default_ttl, $dir_mode, $file_mode)
18
    {
19
        parent::__construct($cache_path, $default_ttl, $dir_mode, $file_mode);
20
21
        $this->time_frozen = parent::getTime();
22
    }
23
24
    protected function getTime()
25
    {
26
        return $this->time_frozen;
27
    }
28
29
    /**
30
     * @param int $seconds
31
     */
32
    public function skipTime($seconds)
33
    {
34
        $this->time_frozen += $seconds;
35
    }
36
37
    /**
38
     * @param string $key
39
     *
40
     * @return string
41
     */
42
    public function getCachePath($key)
43
    {
44
        return $this->getPath($key);
45
    }
46
}
47