Code Duplication    Length = 29-35 lines in 4 locations

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

@@ 28-62 (lines=35) @@
25
 * THE SOFTWARE.
26
 */
27
28
class Apc extends AbstractEnhancedProvider {
29
30
    public function __construct(LoggerInterface $logger = null) {
31
32
        try {
33
34
            $this->driver = new ApcDriver();
35
36
            parent::__construct($logger);
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

@@ 28-56 (lines=29) @@
25
 * THE SOFTWARE.
26
 */
27
28
class Apcu extends AbstractEnhancedProvider {
29
30
    public function __construct(LoggerInterface $logger = null) {
31
32
        try {
33
34
            $this->driver = new ApcuDriver();
35
36
            parent::__construct($logger);
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

@@ 27-61 (lines=35) @@
24
 * THE SOFTWARE.
25
 */
26
27
class Apc extends AbstractEnhancedProvider {
28
29
    public function __construct(LoggerInterface $logger = null) {
30
31
        try {
32
33
            $this->driver = new ApcDriver();
34
35
            parent::__construct($logger);
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

@@ 27-61 (lines=35) @@
24
 * THE SOFTWARE.
25
 */
26
27
class Apcu extends AbstractEnhancedProvider {
28
29
    public function __construct(LoggerInterface $logger = null) {
30
31
        try {
32
33
            $this->driver = new ApcuDriver();
34
35
            parent::__construct($logger);
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