Code Duplication    Length = 17-17 lines in 2 locations

src/Suricate/Cache/Memcache.php 1 location

@@ 84-100 (lines=17) @@
81
        return $this;
82
    }
83
84
    private function connect()
85
    {
86
        if ($this->handler === false) {
87
            if (class_exists('Memcache')) {
88
                try {
89
                    $this->handler = new \Memcache();
90
                    $this->handler->connect($this->host, $this->port);
91
                } catch (\Exception $e) {
92
                    throw new \Exception('Can\'t connect to memcache server');
93
                }
94
            } else {
95
                throw new \BadMethodCallException('Can\'t find Memcache extension');
96
            }
97
        } else {
98
            return $this;
99
        }
100
    }
101
102
    /**
103
     * Put a value into memcache

src/Suricate/Cache/Memcached.php 1 location

@@ 69-85 (lines=17) @@
66
        return $this;
67
    }
68
    
69
    private function connect()
70
    {
71
        if ($this->handler === false) {
72
            if (class_exists('Memcached')) {
73
                try {
74
                    $this->handler = new \Memcached();
75
                    $this->handler->addServer($this->host, $this->port);
76
                } catch (\Exception $e) {
77
                    throw new \Exception('Can\'t connect to memcache server');
78
                }
79
            } else {
80
                throw new \BadMethodCallException('Can\'t find Memcached extension');
81
            }
82
        } else {
83
            return $this;
84
        }
85
    }
86
87
    /**
88
     * Put a value into memcache