Passed
Push — master ( 0c0438...de1b4b )
by Jean-Christophe
09:49
created

DAOMemoryCache   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 18
ccs 5
cts 8
cp 0.625
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 3 2
A store() 0 2 1
A fetch() 0 2 1
1
<?php
2
3
namespace Ubiquity\cache\dao;
4
5
/**
6
 * Simple Memory cache for DAO instances
7
 * Ubiquity\cache\dao$DAOMemoryCache
8
 * This class is part of Ubiquity
9
 *
10
 * @author jc
11
 * @version 1.0.0
12
 *
13
 */
14
class DAOMemoryCache extends AbstractDAOCache {
15
	/**
16
	 *
17
	 * @var array
18
	 */
19
	protected $arrayCache;
20
21 1
	public function store($class, $key, $object) {
22 1
		$this->arrayCache [$class] [$key] = $object;
23 1
	}
24
25 1
	public function fetch($class, $key) {
26 1
		return $this->arrayCache [$class] [$key] ?? false;
27
	}
28
29
	public function delete($class, $key) {
30
		if (isset ( $this->arrayCache [$class] [$key] )) {
31
			unset ( $this->arrayCache [$class] [$key] );
32
		}
33
	}
34
}
35
36