Code Duplication    Length = 110-111 lines in 3 locations

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

@@ 28-138 (lines=111) @@
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 array [
72
     *      'd' => 'THE ITEM DATA'
73
     *      't' => 'THE ITEM DATE EXPIRATION'
74
     *      'g' => 'THE ITEM TAGS'
75
     * ]
76
     */
77
    protected function driverRead(CacheItemInterface $item)
78
    {
79
        return [
80
          self::DRIVER_DATA_WRAPPER_INDEX => null,
81
          self::DRIVER_TAGS_WRAPPER_INDEX => [],
82
          self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(),
83
        ];
84
    }
85
86
    /**
87
     * @param \Psr\Cache\CacheItemInterface $item
88
     * @return bool
89
     * @throws \InvalidArgumentException
90
     */
91
    protected function driverDelete(CacheItemInterface $item)
92
    {
93
        /**
94
         * Check for Cross-Driver type confusion
95
         */
96
        if ($item instanceof Item) {
97
            return true;
98
        } else {
99
            throw new \InvalidArgumentException('Cross-Driver type confusion detected');
100
        }
101
    }
102
103
    /**
104
     * @return bool
105
     */
106
    protected function driverClear()
107
    {
108
        return true;
109
    }
110
111
    /**
112
     * @return bool
113
     */
114
    protected function driverConnect()
115
    {
116
        return true;
117
    }
118
119
    /********************
120
     *
121
     * PSR-6 Extended Methods
122
     *
123
     *******************/
124
125
    /**
126
     * @return driverStatistic
127
     */
128
    public function getStats()
129
    {
130
        $stat = new driverStatistic();
131
        $stat->setInfo('[Devnull] A void info string')
132
          ->setSize(0)
133
          ->setData(implode(', ', array_keys($this->itemInstances)))
134
          ->setRawData(null);
135
136
        return $stat;
137
    }
138
}

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

@@ 28-138 (lines=111) @@
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 array [
72
     *      'd' => 'THE ITEM DATA'
73
     *      't' => 'THE ITEM DATE EXPIRATION'
74
     *      'g' => 'THE ITEM TAGS'
75
     * ]
76
     */
77
    protected function driverRead(CacheItemInterface $item)
78
    {
79
        return [
80
          self::DRIVER_DATA_WRAPPER_INDEX => true,
81
          self::DRIVER_TAGS_WRAPPER_INDEX => [],
82
          self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(),
83
        ];
84
    }
85
86
    /**
87
     * @param \Psr\Cache\CacheItemInterface $item
88
     * @return bool
89
     * @throws \InvalidArgumentException
90
     */
91
    protected function driverDelete(CacheItemInterface $item)
92
    {
93
        /**
94
         * Check for Cross-Driver type confusion
95
         */
96
        if ($item instanceof Item) {
97
            return false;
98
        } else {
99
            throw new \InvalidArgumentException('Cross-Driver type confusion detected');
100
        }
101
    }
102
103
    /**
104
     * @return bool
105
     */
106
    protected function driverClear()
107
    {
108
        return false;
109
    }
110
111
    /**
112
     * @return bool
113
     */
114
    protected function driverConnect()
115
    {
116
        return false;
117
    }
118
119
    /********************
120
     *
121
     * PSR-6 Extended Methods
122
     *
123
     *******************/
124
125
    /**
126
     * @return driverStatistic
127
     */
128
    public function getStats()
129
    {
130
        $stat = new driverStatistic();
131
        $stat->setInfo('[Devtrue] A void info string')
132
          ->setSize(0)
133
          ->setData(implode(', ', array_keys($this->itemInstances)))
134
          ->setRawData(true);
135
136
        return $stat;
137
    }
138
}

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

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