Request   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 57
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSignatureBaseString() 0 12 1
A getSignableParameters() 0 6 1
A signRequest() 0 11 1
A authorizationHeader() 0 11 1
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
7
namespace SocialConnect\OAuth1;
8
9
use SocialConnect\Provider\Consumer;
10
use SocialConnect\OAuth1\Signature\AbstractSignatureMethod;
11
12
class Request extends \SocialConnect\Common\Http\Request
13
{
14
    /**
15
     * @return string
16
     */
17
    public function getSignatureBaseString()
18
    {
19
        $parts = [
20
            $this->method,
21
            $this->uri,
22
            $this->getSignableParameters()
23
        ];
24
25
        $parts = Util::urlencodeRFC3986($parts);
26
27
        return implode('&', $parts);
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getSignableParameters()
34
    {
35
        return Util::buildHttpQuery(
36
            $this->parameters
37
        );
38
    }
39
40
    /**
41
     * @param AbstractSignatureMethod $signatureMethod
42
     * @param Consumer $consumer
43
     * @param Token $token
44
     */
45
    public function signRequest(AbstractSignatureMethod $signatureMethod, Consumer $consumer, Token $token)
46
    {
47
        $this->parameters['oauth_signature_method'] = $signatureMethod->getName();
48
        $this->parameters['oauth_signature'] = $signatureMethod->buildSignature(
49
            $this,
50
            $consumer,
51
            $token
52
        );
53
54
        $this->headers['Authorization'] = $this->authorizationHeader();
55
    }
56
57
    public function authorizationHeader()
58
    {
59
        $parameters = http_build_query(
60
            $this->parameters,
61
            '',
62
            ', ',
63
            PHP_QUERY_RFC3986
64
        );
65
66
        return "OAuth $parameters";
67
    }
68
}
69