Code Duplication    Length = 103-103 lines in 3 locations

src/phpFastCache/Drivers/Devfalse/Driver.php 1 location

@@ 28-130 (lines=103) @@
25
 * Class Driver
26
 * @package phpFastCache\Drivers
27
 */
28
class Driver extends DriverAbstract
29
{
30
    /**
31
     * Driver constructor.
32
     * @param array $config
33
     * @throws phpFastCacheDriverException
34
     */
35
    public function __construct(array $config = [])
36
    {
37
        $this->setup($config);
38
39
        if (!$this->driverCheck()) {
40
            throw new phpFastCacheDriverCheckException(sprintf(self::DRIVER_CHECK_FAILURE, $this->getDriverName()));
41
        }
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function driverCheck()
48
    {
49
        return true;
50
    }
51
52
    /**
53
     * @param \Psr\Cache\CacheItemInterface $item
54
     * @return mixed
55
     * @throws \InvalidArgumentException
56
     */
57
    protected function driverWrite(CacheItemInterface $item)
58
    {
59
        /**
60
         * Check for Cross-Driver type confusion
61
         */
62
        if ($item instanceof Item) {
63
            return true;
64
        } else {
65
            throw new \InvalidArgumentException('Cross-Driver type confusion detected');
66
        }
67
    }
68
69
    /**
70
     * @param \Psr\Cache\CacheItemInterface $item
71
     * @return mixed
72
     */
73
    protected function driverRead(CacheItemInterface $item)
74
    {
75
        return null;
76
    }
77
78
    /**
79
     * @param \Psr\Cache\CacheItemInterface $item
80
     * @return bool
81
     * @throws \InvalidArgumentException
82
     */
83
    protected function driverDelete(CacheItemInterface $item)
84
    {
85
        /**
86
         * Check for Cross-Driver type confusion
87
         */
88
        if ($item instanceof Item) {
89
            return true;
90
        } else {
91
            throw new \InvalidArgumentException('Cross-Driver type confusion detected');
92
        }
93
    }
94
95
    /**
96
     * @return bool
97
     */
98
    protected function driverClear()
99
    {
100
        return true;
101
    }
102
103
    /**
104
     * @return bool
105
     */
106
    protected function driverConnect()
107
    {
108
        return true;
109
    }
110
111
    /********************
112
     *
113
     * PSR-6 Extended Methods
114
     *
115
     *******************/
116
117
    /**
118
     * @return driverStatistic
119
     */
120
    public function getStats()
121
    {
122
        $stat = new driverStatistic();
123
        $stat->setInfo('[Devfalse] A void info string')
124
          ->setSize(0)
125
          ->setData(implode(', ', array_keys($this->itemInstances)))
126
          ->setRawData(false);
127
128
        return $stat;
129
    }
130
}

src/phpFastCache/Drivers/Devnull/Driver.php 1 location

@@ 28-130 (lines=103) @@
25
 * Class Driver
26
 * @package phpFastCache\Drivers
27
 */
28
class Driver extends DriverAbstract
29
{
30
    /**
31
     * Driver constructor.
32
     * @param array $config
33
     * @throws phpFastCacheDriverException
34
     */
35
    public function __construct(array $config = [])
36
    {
37
        $this->setup($config);
38
39
        if (!$this->driverCheck()) {
40
            throw new phpFastCacheDriverCheckException(sprintf(self::DRIVER_CHECK_FAILURE, $this->getDriverName()));
41
        }
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function driverCheck()
48
    {
49
        return true;
50
    }
51
52
    /**
53
     * @param \Psr\Cache\CacheItemInterface $item
54
     * @return mixed
55
     * @throws \InvalidArgumentException
56
     */
57
    protected function driverWrite(CacheItemInterface $item)
58
    {
59
        /**
60
         * Check for Cross-Driver type confusion
61
         */
62
        if ($item instanceof Item) {
63
            return true;
64
        } else {
65
            throw new \InvalidArgumentException('Cross-Driver type confusion detected');
66
        }
67
    }
68
69
    /**
70
     * @param \Psr\Cache\CacheItemInterface $item
71
     * @return mixed
72
     */
73
    protected function driverRead(CacheItemInterface $item)
74
    {
75
        return null;
76
    }
77
78
    /**
79
     * @param \Psr\Cache\CacheItemInterface $item
80
     * @return bool
81
     * @throws \InvalidArgumentException
82
     */
83
    protected function driverDelete(CacheItemInterface $item)
84
    {
85
        /**
86
         * Check for Cross-Driver type confusion
87
         */
88
        if ($item instanceof Item) {
89
            return true;
90
        } else {
91
            throw new \InvalidArgumentException('Cross-Driver type confusion detected');
92
        }
93
    }
94
95
    /**
96
     * @return bool
97
     */
98
    protected function driverClear()
99
    {
100
        return true;
101
    }
102
103
    /**
104
     * @return bool
105
     */
106
    protected function driverConnect()
107
    {
108
        return true;
109
    }
110
111
    /********************
112
     *
113
     * PSR-6 Extended Methods
114
     *
115
     *******************/
116
117
    /**
118
     * @return driverStatistic
119
     */
120
    public function getStats()
121
    {
122
        $stat = new driverStatistic();
123
        $stat->setInfo('[Devnull] A void info string')
124
          ->setSize(0)
125
          ->setData(implode(', ', array_keys($this->itemInstances)))
126
          ->setRawData(null);
127
128
        return $stat;
129
    }
130
}

src/phpFastCache/Drivers/Devtrue/Driver.php 1 location

@@ 28-130 (lines=103) @@
25
 * Class Driver
26
 * @package phpFastCache\Drivers
27
 */
28
class Driver extends DriverAbstract
29
{
30
    /**
31
     * Driver constructor.
32
     * @param array $config
33
     * @throws phpFastCacheDriverException
34
     */
35
    public function __construct(array $config = [])
36
    {
37
        $this->setup($config);
38
39
        if (!$this->driverCheck()) {
40
            throw new phpFastCacheDriverCheckException(sprintf(self::DRIVER_CHECK_FAILURE, $this->getDriverName()));
41
        }
42
    }
43
44
    /**
45
     * @return bool
46
     */
47
    public function driverCheck()
48
    {
49
        return true;
50
    }
51
52
    /**
53
     * @param \Psr\Cache\CacheItemInterface $item
54
     * @return mixed
55
     * @throws \InvalidArgumentException
56
     */
57
    protected function driverWrite(CacheItemInterface $item)
58
    {
59
        /**
60
         * Check for Cross-Driver type confusion
61
         */
62
        if ($item instanceof Item) {
63
            return false;
64
        } else {
65
            throw new \InvalidArgumentException('Cross-Driver type confusion detected');
66
        }
67
    }
68
69
    /**
70
     * @param \Psr\Cache\CacheItemInterface $item
71
     * @return mixed
72
     */
73
    protected function driverRead(CacheItemInterface $item)
74
    {
75
        return false;
76
    }
77
78
    /**
79
     * @param \Psr\Cache\CacheItemInterface $item
80
     * @return bool
81
     * @throws \InvalidArgumentException
82
     */
83
    protected function driverDelete(CacheItemInterface $item)
84
    {
85
        /**
86
         * Check for Cross-Driver type confusion
87
         */
88
        if ($item instanceof Item) {
89
            return false;
90
        } else {
91
            throw new \InvalidArgumentException('Cross-Driver type confusion detected');
92
        }
93
    }
94
95
    /**
96
     * @return bool
97
     */
98
    protected function driverClear()
99
    {
100
        return false;
101
    }
102
103
    /**
104
     * @return bool
105
     */
106
    protected function driverConnect()
107
    {
108
        return false;
109
    }
110
111
    /********************
112
     *
113
     * PSR-6 Extended Methods
114
     *
115
     *******************/
116
117
    /**
118
     * @return driverStatistic
119
     */
120
    public function getStats()
121
    {
122
        $stat = new driverStatistic();
123
        $stat->setInfo('[Devtrue] A void info string')
124
          ->setSize(0)
125
          ->setData(implode(', ', array_keys($this->itemInstances)))
126
          ->setRawData(true);
127
128
        return $stat;
129
    }
130
}