Passed
Pull Request — master (#3)
by Tharanga
03:00
created

GitHubConnectionFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 34
rs 10
c 0
b 0
f 0
ccs 0
cts 14
cp 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 10 1
1
<?php
2
/**
3
 * @author Tharanga Kothalawala <[email protected]>
4
 * @date 29-01-2019
5
 */
6
7
namespace TSK\SSO\ThirdParty\GitHub;
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\GitHub
15
 */
16
class GitHubConnectionFactory implements VendorConnectionFactory
17
{
18
    /**
19
     * @var string
20
     */
21
    private $oauthAppName;
22
23
    /**
24
     * @param string $oauthAppName
25
     */
26
    public function __construct($oauthAppName)
27
    {
28
        $this->oauthAppName = $oauthAppName;
29
    }
30
31
    /**
32
     * Returns a GitHub Connection instance using given credentials. Visit the following link for credentials.
33
     * @see https://github.com/settings/applications/new
34
     *
35
     * @param string $clientId the client id which can be generated at the third party portal
36
     * @param string $clientSecret this can be found similar to the clientId
37
     * @param string $callbackUrl the url to callback after a third party auth attempt
38
     * @return VendorConnection
39
     */
40
    public function get($clientId, $clientSecret, $callbackUrl)
41
    {
42
        return new GitHubConnection(
43
            new GitHubApiConfiguration(
44
                $clientId,
45
                $clientSecret,
46
                $callbackUrl,
47
                $this->oauthAppName
48
            ),
49
            new CurlRequest()
50
        );
51
    }
52
}
53