SlackConnectionFactory::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 10
rs 10
ccs 8
cts 8
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\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