Passed
Push — v7 ( c2ec86...629ebb )
by Georges
01:43
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
 * This file is part of phpFastCache.
5
 *
6
 * @license MIT License (MIT)
7
 *
8
 * For full copyright and license information, please see the docs/CREDITS.txt file.
9
 *
10
 * @author Khoa Bui (khoaofgod)  <[email protected]> http://www.phpfastcache.com
11
 * @author Georges.L (Geolim4)  <[email protected]>
12
 *
13
 */
14
declare(strict_types=1);
15
16
namespace Phpfastcache\Drivers\Devfalse;
17
18
use Phpfastcache\Core\Pool\{
19
  DriverBaseTrait, ExtendedCacheItemPoolInterface
20
};
21
use Phpfastcache\Entities\DriverStatistic;
22
use Phpfastcache\Exceptions\{
23
  PhpfastcacheInvalidArgumentException
24
};
25
use Psr\Cache\CacheItemInterface;
26
27
/**
28
 * Class Driver
29
 * @package phpFastCache\Drivers
30
 * @property Config $config Config object
31
 * @method Config getConfig() Return the config object
32
 */
33
class Driver implements ExtendedCacheItemPoolInterface
34
{
35
    use DriverBaseTrait;
36
37
    /**
38
     * @return bool
39
     */
40
    public function driverCheck(): bool
41
    {
42
        return true;
43
    }
44
45
    /**
46
     * @param \Psr\Cache\CacheItemInterface $item
47
     * @return bool
48
     * @throws PhpfastcacheInvalidArgumentException
49
     */
50
    protected function driverWrite(CacheItemInterface $item): bool
51
    {
52
        /**
53
         * Check for Cross-Driver type confusion
54
         */
55
        if ($item instanceof Item) {
56
            return true;
57
        }
58
59
        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
60
    }
61
62
    /**
63
     * @param \Psr\Cache\CacheItemInterface $item
64
     * @return array
65
     */
66
    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

66
    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...
67
    {
68
        return [
69
          self::DRIVER_DATA_WRAPPER_INDEX => false,
70
          self::DRIVER_TAGS_WRAPPER_INDEX => [],
71
          self::DRIVER_EDATE_WRAPPER_INDEX => new \DateTime(),
72
        ];
73
    }
74
75
    /**
76
     * @param \Psr\Cache\CacheItemInterface $item
77
     * @return bool
78
     * @throws PhpfastcacheInvalidArgumentException
79
     */
80
    protected function driverDelete(CacheItemInterface $item): bool
81
    {
82
        /**
83
         * Check for Cross-Driver type confusion
84
         */
85
        if ($item instanceof Item) {
86
            return true;
87
        }
88
89
        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
90
    }
91
92
    /**
93
     * @return bool
94
     */
95
    protected function driverClear(): bool
96
    {
97
        return true;
98
    }
99
100
    /**
101
     * @return bool
102
     */
103
    protected function driverConnect(): bool
104
    {
105
        return true;
106
    }
107
108
    /**
109
     * @inheritdoc
110
     */
111
    public static function isUsableInAutoContext(): bool
112
    {
113
        return false;
114
    }
115
116
    /********************
117
     *
118
     * PSR-6 Extended Methods
119
     *
120
     *******************/
121
122
    /**
123
     * @return DriverStatistic
124
     */
125
    public function getStats(): DriverStatistic
126
    {
127
        $stat = new DriverStatistic();
128
        $stat->setInfo('[Devfalse] A void info string')
129
          ->setSize(0)
130
          ->setData(\implode(', ', \array_keys($this->itemInstances)))
131
          ->setRawData(false);
132
133
        return $stat;
134
    }
135
}