OAuthToken   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A to_string() 0 6 1
A __construct() 0 6 1
A __toString() 0 3 1
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