LockIdentifierGenerator::generate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 5
rs 10
cc 1
nc 1
nop 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