AbstractIdGenerator::getHash()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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