CacheKeyProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
c 0
b 0
f 0
dl 0
loc 42
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCacheKeyForReferenceList() 0 2 1
A setCachePrefix() 0 2 1
A getCacheKeyForCitationReference() 0 2 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