Passed
Push — master ( bd3cb9...127ddb )
by Jean-Christophe
17:45
created

MemoryCache   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 46.15%

Importance

Changes 0
Metric Value
wmc 6
eloc 12
dl 0
loc 29
ccs 6
cts 13
cp 0.4615
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 7 2
A store() 0 2 1
A fetch() 0 6 2
A __construct() 0 1 1
1
<?php
2
3
namespace Ubiquity\cache\database;
4
5
/**
6
 * Ubiquity\cache\database$MemoryCache
7
 * This class is part of Ubiquity
8
 *
9
 * @author jcheron <[email protected]>
10
 * @version 1.0.1
11
 *
12
 */
13
class MemoryCache extends DbCache {
14
	/**
15
	 *
16
	 * @var array
17
	 */
18
	protected $memoryCache;
19
20
	public function __construct() {
21
	}
22
23 9
	public function fetch($tableName, $condition) {
24 9
		$key = $this->getKey ( $tableName, $condition );
25 9
		if (isset ( $this->memoryCache [$key] )) {
26
			return $this->memoryCache [$key];
27
		}
28 9
		return false;
29
	}
30
31 9
	public function store($tableName, $condition, $result) {
32 9
		$this->memoryCache [$this->getKey ( $tableName, $condition )] = $result;
33
	}
34
35
	public function delete($tableName, $condition) {
36
		$key = $this->getKey ( $tableName, $condition );
37
		if (isset ( $this->memoryCache [$key] )) {
38
			unset ( $this->memoryCache [$key] );
39
			return true;
40
		}
41
		return false;
42
	}
43
}
44