CacheKeyProvider::setCachePrefix()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 2
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace SCI;
4
5
/**
6
 * @license GNU GPL v2+
7
 * @since 1.0
8
 *
9
 * @author mwjames
10
 */
11
class CacheKeyProvider {
12
13
	/**
14
	 * Update the version to force a recache for all items due to
15
	 * required changes
16
	 */
17
	const VERSION = '1.2';
18
19
	/**
20
	 * @var string
21
	 */
22
	private $cachePrefix = '';
23
24
	/**
25
	 * @since 1.0
26
	 *
27
	 * @param string $cachePrefix
28
	 */
29 15
	public function setCachePrefix( $cachePrefix ) {
30 15
		$this->cachePrefix = $cachePrefix;
31 15
	}
32
33
	/**
34
	 * @since 1.0
35
	 *
36
	 * @param string $hash
37
	 *
38
	 * @return string
39
	 */
40 15
	public function getCacheKeyForCitationReference( $hash ) {
41 15
		return $this->cachePrefix . ':sci:ref:' . md5( $hash . self::VERSION );
42
	}
43
44
	/**
45
	 * @since 1.0
46
	 *
47
	 * @param string $hash
48
	 *
49
	 * @return string
50
	 */
51 15
	public function getCacheKeyForReferenceList( $hash ) {
52 15
		return $this->cachePrefix . ':sci:reflist:' . md5( $hash . self::VERSION );
53
	}
54
55
}
56