MethodHMACSHA1::buildSignature()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
rs 10
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