Passed
Push — v7 ( c2ec86...629ebb )
by Georges
01:43
created

Driver::driverConnect()   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\Devtrue;
17
18
use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface};
19
use Phpfastcache\Entities\DriverStatistic;
20
use Phpfastcache\Exceptions\{
21
  PhpfastcacheInvalidArgumentException
22
};
23
use Psr\Cache\CacheItemInterface;
24
25
/**
26
 * Class Driver
27
 * @package phpFastCache\Drivers
28
 * @property Config $config Config object
29
 * @method Config getConfig() Return the config object
30
 */
31
class Driver implements ExtendedCacheItemPoolInterface
32
{
33
    use DriverBaseTrait;
34
35
    /**
36
     * @return bool
37
     */
38
    public function driverCheck(): bool
39
    {
40
        return true;
41
    }
42
43
    /**
44
     * @param \Psr\Cache\CacheItemInterface $item
45
     * @return mixed
46
     * @throws PhpfastcacheInvalidArgumentException
47
     */
48
    protected function driverWrite(CacheItemInterface $item): bool
49
    {
50
        /**
51
         * Check for Cross-Driver type confusion
52
         */
53
        if ($item instanceof Item) {
54
            return false;
55
        }
56
57
        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
58
    }
59
60
    /**
61
     * @param \Psr\Cache\CacheItemInterface $item
62
     * @return array
63
     */
64
    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

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