Completed
Push — master ( be9660...707803 )
by Georges
16s queued 13s
created

Driver::isUsableInAutoContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 *
5
 * This file is part of phpFastCache.
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For full copyright and license information, please see the docs/CREDITS.txt file.
10
 *
11
 * @author Khoa Bui (khoaofgod)  <[email protected]> https://www.phpfastcache.com
12
 * @author Georges.L (Geolim4)  <[email protected]>
13
 *
14
 */
15
declare(strict_types=1);
16
17
namespace Phpfastcache\Drivers\Devfalse;
18
19
use DateTime;
20
use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface};
21
use Phpfastcache\Entities\DriverStatistic;
22
use Phpfastcache\Exceptions\{PhpfastcacheInvalidArgumentException};
23
use Psr\Cache\CacheItemInterface;
24
25
26
/**
27
 * Class Driver
28
 * @package phpFastCache\Drivers
29
 * @property Config $config Config object
30
 * @method Config getConfig() Return the config object
31
 */
32
class Driver implements ExtendedCacheItemPoolInterface
33
{
34
    use DriverBaseTrait;
35
36
    /**
37
     * @return bool
38
     */
39
    public function driverCheck(): bool
40
    {
41
        return true;
42
    }
43
44
    /**
45
     * @return DriverStatistic
46
     */
47
    public function getStats(): DriverStatistic
48
    {
49
        $stat = new DriverStatistic();
50
        $stat->setInfo('[Devfalse] A void info string')
51
            ->setSize(0)
52
            ->setData(implode(', ', array_keys($this->itemInstances)))
53
            ->setRawData(false);
54
55
        return $stat;
56
    }
57
58
    /**
59
     * @param CacheItemInterface $item
60
     * @return bool
61
     * @throws PhpfastcacheInvalidArgumentException
62
     */
63
    protected function driverWrite(CacheItemInterface $item): bool
64
    {
65
        /**
66
         * Check for Cross-Driver type confusion
67
         */
68
        if ($item instanceof Item) {
69
            return true;
70
        }
71
72
        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
73
    }
74
75
    /**
76
     * @param CacheItemInterface $item
77
     * @return array
78
     */
79
    protected function driverRead(CacheItemInterface $item): array
1 ignored issue
show
Unused Code introduced by
The parameter $item is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

79
    protected function driverRead(/** @scrutinizer ignore-unused */ CacheItemInterface $item): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
80
    {
81
        return [
82
            self::DRIVER_DATA_WRAPPER_INDEX => false,
83
            self::DRIVER_TAGS_WRAPPER_INDEX => [],
84
            self::DRIVER_EDATE_WRAPPER_INDEX => new DateTime(),
85
        ];
86
    }
87
88
    /**
89
     * @param CacheItemInterface $item
90
     * @return bool
91
     * @throws PhpfastcacheInvalidArgumentException
92
     */
93
    protected function driverDelete(CacheItemInterface $item): bool
94
    {
95
        /**
96
         * Check for Cross-Driver type confusion
97
         */
98
        if ($item instanceof Item) {
99
            return true;
100
        }
101
102
        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
103
    }
104
105
    /**
106
     * @return bool
107
     */
108
    protected function driverClear(): bool
109
    {
110
        return true;
111
    }
112
113
    /********************
114
     *
115
     * PSR-6 Extended Methods
116
     *
117
     *******************/
118
119
    /**
120
     * @return bool
121
     */
122
    protected function driverConnect(): bool
123
    {
124
        return true;
125
    }
126
}