Passed
Push — master ( 33e63f...3377ec )
by Tharanga
06:29
created

GitHubConnectionFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 34
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 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 1
    public function __construct($oauthAppName)
27
    {
28 1
        $this->oauthAppName = $oauthAppName;
29 1
    }
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 1
    public function get($clientId, $clientSecret, $callbackUrl)
41
    {
42 1
        return new GitHubConnection(
43 1
            new GitHubApiConfiguration(
44 1
                $clientId,
45 1
                $clientSecret,
46 1
                $callbackUrl,
47 1
                $this->oauthAppName
48 1
            ),
49 1
            new CurlRequest()
50 1
        );
51
    }
52
}
53