OAuthToken::to_string()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Omnipay\Pesapal\OAuth;
4
5
class OAuthToken
6
{
7
    /**
8
     * @var string
9
     */
10
    public $key;
11
12
    /**
13
     * @var string
14
     */
15
    public $secret;
16
17
    /**
18
     * key = the token
19
     * secret = the token secret.
20
     */
21
    public function __construct(
22
        string $key,
23
        string $secret
24
    ) {
25
        $this->key = $key;
26
        $this->secret = $secret;
27
    }
28
29
    /**
30
     * generates the basic string serialization of a token that a server
31
     * would respond to request_token and access_token calls with.
32
     */
33
    public function to_string() : string
34
    {
35
        return 'oauth_token='.
36
               OAuthUtil::urlencode_rfc3986($this->key).
37
               '&oauth_token_secret='.
38
               OAuthUtil::urlencode_rfc3986($this->secret);
39
    }
40
41
    /**
42
     * @return string
43
     */
44
    public function __toString(): string
45
    {
46
        return $this->to_string();
47
    }
48
}
49