LinkedInConnectionFactory::__construct()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
/**
3
 * @author Tharanga Kothalawala <[email protected]>
4
 * @date 31-12-2018
5
 */
6
7
namespace TSK\SSO\ThirdParty\LinkedIn;
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\LinkedIn
15
 */
16
class LinkedInConnectionFactory implements VendorConnectionFactory
17
{
18
    /**
19
     * @var string
20
     */
21
    private $permissions;
22
23
    /**
24
     * @param string $permissions
25
     */
26 1
    public function __construct($permissions = 'r_basicprofile,r_emailaddress')
27
    {
28 1
        $this->permissions = $permissions;
29 1
    }
30
31
    /**
32
     * @param string $clientId the client id which can be generated at the third party portal
33
     * @param string $clientSecret this can be found similar to the clientId
34
     * @param string $callbackUrl the url to callback after a third party auth attempt
35
     * @return VendorConnection
36
     */
37 1
    public function get($clientId, $clientSecret, $callbackUrl)
38
    {
39 1
        return new LinkedInConnection(
40 1
            new LinkedInApiConfiguration($clientId, $clientSecret, $this->permissions, $callbackUrl),
41 1
            new CurlRequest()
42 1
        );
43
    }
44
}
45