LockIdentifierGenerator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 3
c 1
b 0
f 1
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jellyfish\LockSymfony;
6
7
use Jellyfish\Lock\LockIdentifierGeneratorInterface;
8
9
use function implode;
10
use function sha1;
11
use function sprintf;
12
13
class LockIdentifierGenerator implements LockIdentifierGeneratorInterface
14
{
15
    protected const IDENTIFIER_PREFIX = 'lock';
16
17
    /**
18
     * @param array $identifierParts
19
     *
20
     * @return string
21
     */
22
    public function generate(array $identifierParts): string
23
    {
24
        $identifierWithoutPrefix = sha1(implode(' ', $identifierParts));
25
26
        return sprintf('%s:%s', static::IDENTIFIER_PREFIX, $identifierWithoutPrefix);
27
    }
28
}
29