OAuth1::authenticate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Xabbuh\Http\Authentication;
4
5
use ApiClients\Tools\Psr7\Oauth1\Definition\AccessToken;
6
use ApiClients\Tools\Psr7\Oauth1\Definition\TokenSecret;
7
use ApiClients\Tools\Psr7\Oauth1\RequestSigning\RequestSigner;
8
use Http\Message\Authentication;
9
use Psr\Http\Message\RequestInterface;
10
11
/**
12
 * Adds a signed Authorization header using the configured OAuth1 request signer and credentials.
13
 *
14
 * @author Christian Flothmann <[email protected]>
15
 */
16
final class OAuth1 implements Authentication
17
{
18
    private $requestSigner;
19
20
    public function __construct(RequestSigner $requestSigner, AccessToken $accessToken, TokenSecret $tokenSecret)
21
    {
22
        $this->requestSigner = $requestSigner->withAccessToken($accessToken, $tokenSecret);
23
    }
24
25
    public function authenticate(RequestInterface $request)
26
    {
27
        return $this->requestSigner->sign($request);
28
    }
29
}
30