AbstractIdGenerator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 4
c 1
b 0
f 0
dl 0
loc 20
ccs 3
cts 3
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getHash() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Ctw\Middleware\PageCacheMiddleware\IdGenerator;
5
6
abstract class AbstractIdGenerator
7
{
8
    /**
9
     * Emergency invalidation salt.
10
     *
11
     * When making substantial changes to this package,
12
     * all existing cached files can be invalided by changing this value.
13
     *
14
     * @var string
15
     */
16
    protected const SALT = 'rhi0skgJnnyMvEwxVkSiOZK6wtIcX6lZlGuXRrAu';
17
18
    /**
19
     * Return a SHA256 hash for the passed $vars
20
     */
21 4
    protected function getHash(array $vars): string
22
    {
23 4
        $data = implode('|', array_filter($vars));
24
25 4
        return hash('sha256', $data);
26
    }
27
}
28