Completed
Push — master ( 6219f7...d44e26 )
by David
13s
created

UserContextInvalidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A invalidateContext() 0 4 1
A buildTag() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCacheBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCacheBundle;
13
14
use FOS\HttpCache\ProxyClient\Invalidation\TagCapable;
15
16
class UserContextInvalidator
17
{
18
    const USER_CONTEXT_TAG_PREFIX = 'fos_http_cache_hashlookup-';
19
20
    /**
21
     * @var TagCapable
22
     */
23
    private $tagger;
24
25 4
    public function __construct(TagCapable $tagger)
26
    {
27 4
        $this->tagger = $tagger;
28 4
    }
29
30
    /**
31
     * Invalidate the user context hash.
32
     *
33
     * @param string $sessionId
34
     */
35 1
    public function invalidateContext($sessionId)
36
    {
37 1
        $this->tagger->invalidateTags([static::buildTag($sessionId)]);
38 1
    }
39
40 2
    public static function buildTag($hash)
41
    {
42 2
        return static::USER_CONTEXT_TAG_PREFIX.$hash;
43
    }
44
}
45