Completed
Pull Request — master (#6)
by Risan Bagja
01:31
created

AuthorizationHeader::forTemporaryCredentials()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Risan\OAuth1\Request;
4
5
use Risan\OAuth1\Credentials\TemporaryCredentials;
6
7
class AuthorizationHeader implements AuthorizationHeaderInterface
8
{
9
    /**
10
     * The ProtocolParameterInterface instance.
11
     *
12
     * @var \Risan\OAuth1\Request\ProtocolParameterInterface
13
     */
14
    protected $protocolParameter;
15
16
    /**
17
     * Create a new instance of AuthorizationHeader class.
18
     *
19
     * @param \Risan\OAuth1\Request\ProtocolParameterInterface $protocolParameter
20
     */
21 4
    public function __construct(ProtocolParameterInterface $protocolParameter)
22
    {
23 4
        $this->protocolParameter = $protocolParameter;
24 4
    }
25
26
    /**
27
     * {@inheritDoc}
28
     */
29 1
    public function getProtocolParameter()
30
    {
31 1
        return $this->protocolParameter;
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37 1
    public function forTemporaryCredentials()
38
    {
39 1
        return $this->normalizeProtocolParameters(
40 1
            $this->protocolParameter->forTemporaryCredentials()
41
        );
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47 1
    public function forTokenCredentials(TemporaryCredentials $temporaryCredentials, $verificationCode)
48
    {
49 1
        return $this->normalizeProtocolParameters(
50 1
            $this->protocolParameter->forTokenCredentials($temporaryCredentials, $verificationCode)
51
        );
52
    }
53
54
    /**
55
     * {@inheritDoc}
56
     */
57 View Code Duplication
    public function normalizeProtocolParameters(array $parameters)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59 3
        array_walk($parameters, function (&$value, $key) {
60 3
            $value = rawurlencode($key) . '="' . rawurlencode($value) . '"';
61 3
        });
62
63
        return 'OAuth ' . implode(', ', $parameters);
64
    }
65
}
66