SimpleInMemoryCache   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 17
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 2
A has() 0 3 1
A set() 0 3 1
1
<?php
2
3
namespace SimpleCache\Cache;
4
5
/**
6
 * Very simple in memory cache. Entries are kept around until the object gets destructed.
7
 *
8
 * @licence GNU GPL v2+
9
 * @author Jeroen De Dauw < [email protected] >
10
 */
11
class SimpleInMemoryCache implements Cache {
12
13
	protected $memoryCache = array();
14
15 11
	public function get( $key ) {
16 11
		return array_key_exists( $key, $this->memoryCache ) ? $this->memoryCache[$key] : null;
17
	}
18
19 11
	public function has( $key ) {
20 11
		return array_key_exists( $key, $this->memoryCache );
21
	}
22
23 11
	public function set( $key, $value ) {
24 11
		$this->memoryCache[$key] = $value;
25 11
	}
26
27
}
28