HashHmac   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A sign() 0 3 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Signature Provider Class
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\AeSdk\Infrastructure\Provider\Signature\Algorithm\Hash;
11
12
use Ticaje\AeSdk\Infrastructure\Interfaces\Provider\Signature\ComplexAlgorithmInterface;
13
14
/**
15
 * Class HashHmac
16
 * @package Ticaje\AeSdk\Infrastructure\Provider\Signature\Algorithm\Hash
17
 */
18
class HashHmac implements ComplexAlgorithmInterface
19
{
20
    protected $algorithm;
21
22
    /**
23
     * HashHmac constructor.
24
     * @param string $algorithm
25
     */
26
    public function __construct(
27
        string $algorithm = 'md5'
28
    ) {
29
        $this->algorithm = $algorithm;
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function sign(string $message, string $secret): string
36
    {
37
        return hash_hmac($this->algorithm, $message, $secret);
38
    }
39
}
40