FacebookConnectionFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 8
rs 10
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
/**
3
 * @author Tharanga Kothalawala <[email protected]>
4
 * @date 30-12-2018
5
 */
6
7
namespace TSK\SSO\ThirdParty\Facebook;
8
9
use TSK\SSO\ThirdParty\VendorConnection;
10
use TSK\SSO\ThirdParty\VendorConnectionFactory;
11
use TSK\SSO\Storage\ThirdPartyStorageRepository;
12
13
/**
14
 * @package TSK\SSO\ThirdParty\Facebook
15
 */
16
class FacebookConnectionFactory implements VendorConnectionFactory
17
{
18
    /**
19
     * @var ThirdPartyStorageRepository
20
     */
21
    private $storageRepository;
22
23
    /**
24
     * @var string
25
     */
26
    private $defaultGraphVersion;
27
28
    /**
29
     * @var string
30
     */
31
    private $permissions;
32
33 1
    public function __construct(
34
        ThirdPartyStorageRepository $storageRepository,
35
        $defaultGraphVersion = 'v2.12',
36
        $permissions = 'public_profile,email'
37
    ) {
38 1
        $this->storageRepository = $storageRepository;
39 1
        $this->defaultGraphVersion = $defaultGraphVersion;
40 1
        $this->permissions = $permissions;
41 1
    }
42
43
    /**
44
     * @param string $clientId the client id which can be generated at the third party portal
45
     * @param string $clientSecret this can be found similar to the clientId
46
     * @param string $callbackUrl the url to callback after a third party auth attempt
47
     * @return VendorConnection
48
     */
49 1
    public function get($clientId, $clientSecret, $callbackUrl)
50
    {
51 1
        return new FacebookConnection(
52 1
            new FacebookApiConfiguration(
53 1
                $this->defaultGraphVersion,
54 1
                $clientId,
0 ignored issues
show
Bug introduced by
$clientId of type string is incompatible with the type integer expected by parameter $appId of TSK\SSO\ThirdParty\Faceb...guration::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

54
                /** @scrutinizer ignore-type */ $clientId,
Loading history...
55 1
                $clientSecret,
56 1
                $this->permissions,
57
                $callbackUrl
58 1
            ),
59 1
            $this->storageRepository
60 1
        );
61
    }
62
}
63