CacheNull::enable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Cachearium\Backend;
4
5
use Cachearium\CacheAbstract;
6
use Cachearium\CacheKey;
7
use Cachearium\CacheData;
8
use Cachearium\CacheLogEnum;
9
use Cachearium\Exceptions\NotCachedException;
10
11
/**
12
 * Null cache class. Does nothing but implements all required methods.
13
 *
14
 */
15
class CacheNull extends CacheAbstract {
16
	// @codeCoverageIgnoreStart
17
	/**
18
	 * Cache constructor (this is a singleton).
19
	 *
20
	 * @return Cache The cache singleton.
21
	 */
22
	public static function singleton() {
23
		static $instances;
24
25
		if (!isset($instances)) {
26
			$instances = new CacheNull();
27
		}
28
		return $instances;
29
	}
30
31
	// Prevent users to clone the instance
32
	public function __clone() {
33
		trigger_error('Cloning is not allowed.', LH_TRIGGER_UNEXPECTED);
34
	}
35
	// @codeCoverageIgnoreEnd
36
37
	/**
38
	 * Constructor.
39
	 * @codeCoverageIgnore
40
	 */
41
	private function __construct() {
42
		$this->disable();
43
	}
44
45
	public function enable() {
46
	}
47
48
	public function get(CacheKey $k) {
49
		throw new NotCachedException();
50
	}
51
52
	public function increment($value, CacheKey $k, $default = 0) {
53
		return $default;
54
	}
55
56
	public function store($data, CacheKey $k, $lifetime = 0) {
57
		return true;
58
	}
59
60
	public function delete(CacheKey $k) {
61
		return true;
62
	}
63
64
	public function cleanP($base, $id) {
65
		return true;
66
	}
67
68
	public function clear() {
69
		return true;
70
	}
71
72
	public function start(CacheKey $k, $lifetime = null, $print = true, $fail = false) {
73
		return false;
74
	}
75
76
	public function end($print = true) {
77
		return '';
78
	}
79
80
	public function prefetch($data) {
81
	}
82
83
	/**
84
	 * @codeCoverageIgnore
85
	 */
86
	protected function hashKey(CacheKey $k) {
87
		return $k->getBase() . $k->getId() . serialize($k->getSub());
88
	}
89
90
	/**
91
	 * @codeCoverageIgnore
92
	 */
93
	public function report() {
94
	}
95
}
96