FileCacheDriver::remove()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MidasSoft\DominicanBankParser\Cache;
4
5
class FileCacheDriver extends AbstractCacheDriver
6
{
7
    /**
8
     * The config of the driver.
9
     *
10
     * @var array
11
     */
12
    protected $config = [
13
        'path'     => '',
14
        'timezone' => 'America/Santo_Domingo',
15
    ];
16
17
    /**
18
     * Creates a new FileCacheDriver instance.
19
     *
20
     * @param array $config
21
     */
22 4
    public function __construct(array $config)
23
    {
24 4
        $this->config = $config;
25 4
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 4
    public function add($key, $value)
31
    {
32 4
        $filename = sprintf('%s/%s.txt', $this->config['path'], $key);
33 4
        $file = file_put_contents($filename, serialize($value));
0 ignored issues
show
Unused Code introduced by
The assignment to $file is dead and can be removed.
Loading history...
34 4
        $this->keys[] = $key;
35 4
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 1
    public function get($key)
41
    {
42 1
        $filename = sprintf('%s/%s.txt', $this->config['path'], $key);
43
44 1
        return unserialize(file_get_contents($filename));
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 1
    public function remove($key)
51
    {
52 1
        unlink(sprintf('%s/%s.txt', $this->config['path'], $key));
53 1
    }
54
}
55