SlackConnectionFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 30
rs 10
ccs 11
cts 11
cp 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 10 1
A __construct() 0 3 1
1
<?php
2
/**
3
 * @author Tharanga Kothalawala <[email protected]>
4
 * @date 31-12-2018
5
 */
6
7
namespace TSK\SSO\ThirdParty\Slack;
8
9
use TSK\SSO\ThirdParty\VendorConnection;
10
use TSK\SSO\ThirdParty\VendorConnectionFactory;
11
use TSK\SSO\Http\CurlRequest;
12
13
/**
14
 * @package TSK\SSO\ThirdParty\Slack
15
 */
16
class SlackConnectionFactory implements VendorConnectionFactory
17
{
18
    const DEFAULT_PERMISSIONS = 'identity.basic,identity.email,identity.team,identity.avatar';
19
20
    /**
21
     * @var string
22
     */
23
    private $permissions;
24
25 1
    public function __construct($permissions = self::DEFAULT_PERMISSIONS)
26
    {
27 1
        $this->permissions = $permissions;
28 1
    }
29
30
    /**
31
     * @param string $clientId the client id which can be generated at the third party portal
32
     * @param string $clientSecret this can be found similar to the clientId
33
     * @param string $callbackUrl the url to callback after a third party auth attempt
34
     * @return VendorConnection
35
     */
36 1
    public function get($clientId, $clientSecret, $callbackUrl)
37
    {
38 1
        return new SlackConnection(
39 1
            new SlackApiConfiguration(
40 1
                $clientId,
41 1
                $clientSecret,
42 1
                $this->permissions,
43
                $callbackUrl
44 1
            ),
45 1
            new CurlRequest()
46 1
        );
47
    }
48
}
49