Completed
Pull Request — master (#1)
by Tharanga
09:26
created

TwitterConnectionFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Tharanga Kothalawala <[email protected]>
4
 * @date 13-01-2019
5
 */
6
7
namespace TSK\SSO\ThirdParty\Twitter;
8
9
use TSK\SSO\Http\CurlRequest;
10
use TSK\SSO\ThirdParty\VendorConnection;
11
use TSK\SSO\ThirdParty\VendorConnectionFactory;
12
13
/**
14
 * @package TSK\SSO\ThirdParty\Twitter
15
 */
16
class TwitterConnectionFactory implements VendorConnectionFactory
17
{
18
    /**
19
     * @var string
20
     */
21
    private $oauthToken;
22
23
    /**
24
     * @var string
25
     */
26
    private $oauthTokenSecret;
27
28
    /**
29
     * TwitterConnectionFactory constructor.
30
     * @param string $oauthToken
31
     * @param string $oauthTokenSecret
32
     */
33
    public function __construct($oauthToken, $oauthTokenSecret)
34
    {
35
        $this->oauthToken = $oauthToken;
36
        $this->oauthTokenSecret = $oauthTokenSecret;
37
    }
38
39
    /**
40
     * @param string $clientId the client id which can be generated at the third party portal
41
     * @param string $clientSecret this can be found similar to the clientId
42
     * @param string $callbackUrl the url to callback after a third party auth attempt
43
     * @return VendorConnection
44
     */
45
    public function get($clientId, $clientSecret, $callbackUrl)
46
    {
47
        return new TwitterConnection(
48
            new TwitterApiConfiguration(
49
                $clientId,
50
                $clientSecret,
51
                $this->oauthToken,
52
                $this->oauthTokenSecret,
53
                $callbackUrl
54
            )
55
        );
56
    }
57
}
58