Passed
Push — master ( 505d49...e3b573 )
by Dmitry
01:50
created

JWTOptions::__construct()   B

Complexity

Conditions 6
Paths 2

Size

Total Lines 25
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 6
eloc 10
nc 2
nop 1
dl 0
loc 25
rs 8.439
c 1
b 0
f 1
1
<?php
2
3
namespace UAPAY;
4
5
use UAPAY\Log as Log;
6
use UAPAY\Exception;
7
8
class JWTOptions
9
{
10
    /**
11
     *      @var array
12
     */
13
    protected $jwt=array(
14
        'using'         => false,
15
        'UAPAY_pubkey'  => '',
16
        'our_privkey'   => '',
17
    );
18
19
    /**
20
     *      Constructor
21
     *
22
     *      @param array $options array of options
23
     *      @throws Exception\Data
24
     */
25
    public function __construct($options)
26
    {
27
        if (isset($options['jwt']))
28
        {
29
            // using
30
            if ( ! isset($options['jwt']['using']))
31
            {
32
                throw new Exception\Data('parameter jwt/using is not specified');
33
            }
34
            if ( ! is_bool($options['jwt']['using']))
35
            {
36
                throw new Exception\Data('parameter jwt/using is incorrect');
37
            }
38
            // using
39
            if ( ! isset($options['jwt']['UAPAY_pubkey']))
40
            {
41
                throw new Exception\Data('parameter jwt/UAPAY_pubkey is not specified');
42
            }
43
            // using
44
            if ( ! isset($options['jwt']['our_privkey']))
45
            {
46
                throw new Exception\Data('parameter jwt/our_privkey is not specified');
47
            }
48
49
            $this->jwt = $options['jwt'];
50
        }
51
    }
52
53
    /**
54
     *      Get jwt options
55
     *
56
     *      @return array
57
     */
58
    public function get()
59
    {
60
        return $this->jwt;
61
    }
62
}
63