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

GitHubConnectionFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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