MethodHMACSHA1   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A buildSignature() 0 8 1
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
declare(strict_types=1);
7
8
namespace SocialConnect\OAuth1\Signature;
9
10
use SocialConnect\Provider\Consumer;
11
use SocialConnect\OAuth1\Token;
12
use SocialConnect\OAuth1\Util;
13
14
class MethodHMACSHA1 extends AbstractSignatureMethod
15
{
16
    /**
17
     * @return string
18
     */
19 4
    public function getName()
20
    {
21 4
        return 'HMAC-SHA1';
22
    }
23
24
    /**
25
     * {@inheritDoc}
26
     */
27 5
    public function buildSignature(string $signatureBase, Consumer $consumer, Token $token)
28
    {
29 5
        $parts = [$consumer->getSecret(), $token->getSecret()];
30
31 5
        $parts = Util::urlencodeRFC3986($parts);
32 5
        $key = implode('&', $parts);
33
34 5
        return base64_encode(hash_hmac('sha1', $signatureBase, $key, true));
35
    }
36
}
37