UserContextInvalidator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
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 3
    public function __construct(TagCapable $tagger)
26
    {
27 3
        $this->tagger = $tagger;
28 3
    }
29
30
    /**
31
     * Invalidate the user context hash.
32
     *
33
     * @param string $sessionId
34
     */
35 2
    public function invalidateContext($sessionId)
36
    {
37 2
        $this->tagger->invalidateTags([static::buildTag($sessionId)]);
38 2
    }
39
40 3
    public static function buildTag($hash)
41
    {
42 3
        return static::USER_CONTEXT_TAG_PREFIX.$hash;
43
    }
44
}
45