Configuration::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
c 1
b 1
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
1
<?php
2
3
namespace XoopsModules\Wggithub\Github\OAuth;
4
5
use XoopsModules\Wggithub\Github;
6
7
8
/**
9
 * Configuration for OAuth token obtaining.
10
 *
11
 * @author  Miloslav Hůla (https://github.com/milo)
12
 */
13
class Configuration extends Github\Sanity
14
{
15
    /** @var string */
16
    public $clientId;
17
18
    /** @var string */
19
    public $clientSecret;
20
21
    /** @var string[] */
22
    public $scopes;
23
24
25
    /**
26
     * @param  string
27
     * @param  string
28
     * @param  string[]
29
     */
30
    public function __construct($clientId, $clientSecret, array $scopes = [])
31
    {
32
        $this->clientId = $clientId;
33
        $this->clientSecret = $clientSecret;
34
        $this->scopes = $scopes;
35
    }
36
37
38
    /**
39
     * @param array $conf
40
     * @return Configuration
41
     */
42
    public static function fromArray(array $conf)
43
    {
44
        return new static($conf['clientId'], $conf['clientSecret'], isset($conf['scopes']) ? $conf['scopes'] : []);
45
    }
46
47
}
48