Code Duplication    Length = 17-21 lines in 2 locations

src/CacheManager.php 2 locations

@@ 153-169 (lines=17) @@
150
     * @return  \Comodojo\Cache\CacheObject\CacheObject
151
     * @throws  \Comodojo\Exception\CacheException
152
     */
153
    final public function setTime($time = null) {
154
        
155
        if ( is_null($time) ) $this->current_time = time();
156
157
        else if ( preg_match('/^[0-9]{10}$/', $time) ) $this->current_time = $time;
158
        
159
        else {
160
            
161
            throw new CacheException("Invalid time");
162
            
163
        }
164
165
        foreach ( $this->caches as $cache ) $cache->setTime($time);
166
167
        return $this;
168
        
169
    }
170
171
    /**
172
     * Set time to live for cache
@@ 179-199 (lines=21) @@
176
     * @return \Comodojo\Cache\CacheObject\CacheObject
177
     * @throws \Comodojo\Exception\CacheException
178
     */
179
    final public function setTtl($ttl = null) {
180
        
181
        if ( is_null($ttl) ) {
182
            
183
            $this->ttl = defined('COMODOJO_CACHE_DEFAULT_TTL') ? COMODOJO_CACHE_DEFAULT_TTL : 3600;
184
            
185
        } else if ( is_int($ttl) ) {
186
            
187
            $this->ttl = $ttl;
188
            
189
        } else {
190
191
            throw new CacheException("Invalid time to live");
192
            
193
        }
194
195
        foreach ( $this->caches as $cache ) $cache->setTtl($ttl);
196
197
        return $this;
198
        
199
    }
200
201
    /**
202
     * Set namespace for cache