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

UserContextInvalidator::buildTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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