Completed
Push — master ( 156e6d...37b0e3 )
by Marcel
03:16
created

HashCalculator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A hmac() 0 4 1
1
<?php
2
3
namespace UMA\Psr\Http\Message\Internal;
4
5
use UMA\Psr\Http\Message\HMAC\Specification;
6
7
class HashCalculator
8
{
9
    /**
10
     * @param string $data The string to be signed
11
     * @param string $key  The secret with which to sign it
12
     *
13
     * @return string A base64-encoded SHA256 hash (so it is guaranteed to be 44 bytes long)
14
     */
15 91
    public function hmac($data, $key)
16
    {
17 91
        return base64_encode(hash_hmac(Specification::HASH_ALGORITHM, $data, $key, true));
18
    }
19
}
20