Code Duplication    Length = 31-37 lines in 4 locations

src/Comodojo/Cache/Providers/Apc.php 1 location

@@ 26-62 (lines=37) @@
23
 * THE SOFTWARE.
24
 */
25
26
class Apc extends AbstractEnhancedProvider {
27
28
    public function __construct(array $properties = [], LoggerInterface $logger = null) {
29
30
        try {
31
32
            parent::__construct($properties, $logger);
33
34
            $this->driver = new ApcDriver();
35
36
            $this->test();
37
38
        } catch (Exception $e) {
39
40
            throw new CacheException($e->getMessage());
41
42
        }
43
44
    }
45
46
    public function getStats() {
47
48
        $info = $this->driver->stats();
49
50
        $entries = isset($info['num_entries']) ? $info['num_entries'] : null;
51
52
        return new EnhancedCacheItemPoolStats(
53
            $this->getId(),
54
            $this->driver->getName(),
55
            $this->getState(),
56
            $entries,
57
            $info
58
        );
59
60
    }
61
62
}
63

src/Comodojo/Cache/Providers/Apcu.php 1 location

@@ 26-56 (lines=31) @@
23
 * THE SOFTWARE.
24
 */
25
26
class Apcu extends AbstractEnhancedProvider {
27
28
    public function __construct(array $properties = [], LoggerInterface $logger = null) {
29
30
        try {
31
32
            parent::__construct($properties, $logger);
33
34
            $this->driver = new ApcuDriver();
35
36
            $this->test();
37
38
        } catch (Exception $e) {
39
40
            throw new CacheException($e->getMessage());
41
42
        }
43
44
    }
45
46
    public function getStats() {
47
48
        $info = $this->driver->stats();
49
50
        $entries = isset($info['num_entries']) ? $info['num_entries'] : null;
51
52
        return new EnhancedCacheItemPoolStats($this->getId(), $this->driver->getName(), $this->getState(), $entries, $info);
53
54
    }
55
56
}
57

src/Comodojo/SimpleCache/Providers/Apc.php 1 location

@@ 25-61 (lines=37) @@
22
 * THE SOFTWARE.
23
 */
24
25
class Apc extends AbstractEnhancedProvider {
26
27
    public function __construct(array $properties = [], LoggerInterface $logger = null) {
28
29
        try {
30
31
            parent::__construct($properties, $logger);
32
33
            $this->driver = new ApcDriver();
34
35
            $this->test();
36
37
        } catch (Exception $e) {
38
39
            throw new SimpleCacheException($e->getMessage());
40
41
        }
42
43
    }
44
45
    public function getStats() {
46
47
        $info = $this->driver->stats();
48
49
        $entries = isset($info['num_entries']) ? $info['num_entries'] : null;
50
51
        return new EnhancedCacheItemPoolStats(
52
            $this->getId(),
53
            $this->driver->getName(),
54
            $this->getState(),
55
            $entries,
56
            $info
57
        );
58
59
    }
60
61
}
62

src/Comodojo/SimpleCache/Providers/Apcu.php 1 location

@@ 25-61 (lines=37) @@
22
 * THE SOFTWARE.
23
 */
24
25
class Apcu extends AbstractEnhancedProvider {
26
27
    public function __construct(array $properties = [], LoggerInterface $logger = null) {
28
29
        try {
30
31
            parent::__construct($properties, $logger);
32
33
            $this->driver = new ApcuDriver();
34
35
            $this->test();
36
37
        } catch (Exception $e) {
38
39
            throw new SimpleCacheException($e->getMessage());
40
41
        }
42
43
    }
44
45
    public function getStats() {
46
47
        $info = $this->driver->stats();
48
49
        $entries = isset($info['num_entries']) ? $info['num_entries'] : null;
50
51
        return new EnhancedCacheItemPoolStats(
52
            $this->getId(),
53
            $this->driver->getName(),
54
            $this->getState(),
55
            $entries,
56
            $info
57
        );
58
59
    }
60
61
}
62