AbstractGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 42
ccs 13
cts 13
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A Sign() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Urvin\Gokaru\Signature;
6
7
abstract class AbstractGenerator implements Generator
8
{
9
    /** @var string */
10
    protected string $salt;
11
12
    /**
13
     * @param string $salt
14
     */
15 42
    public function __construct(string $salt)
16
    {
17 42
        $this->salt = $salt;
18 42
    }
19
20
    /**
21
     * @inheritDoc
22
     */
23 11
    public function Sign(
24
        string $sourceType,
25
        string $category,
26
        string $fileName,
27
        int $width,
28
        int $height,
29
        int $cast
30
    ): string {
31 11
        return $this->hash(
32 11
            implode('/', [
33 11
                $this->salt,
34 11
                $sourceType,
35 11
                $category,
36 11
                $fileName,
37 11
                (string)$width,
38 11
                (string)$height,
39 11
                (string)$cast
40
            ])
41
        );
42
    }
43
44
    /**
45
     * @param string $input
46
     * @return string
47
     */
48
    abstract protected function hash(string $input): string;
49
}