Issues (3)

src/Cache/FileCacheDriver.php (1 issue)

Severity
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
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