Passed
Push — master ( e6e1e5...994cd1 )
by Vadim
09:00 queued 05:57
created

CredentialsOptions   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 63
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 4
A getKey() 0 7 2
A setKey() 0 5 1
A getSecret() 0 7 2
A setSecret() 0 5 1
1
<?php
2
3
namespace AudioManager\Adapter\Polly;
4
5
use AudioManager\Exception\RuntimeException;
6
7
/**
8
 * @package Adapter\Polly
9
 */
10
class CredentialsOptions
11
{
12
    protected $key;
13
    protected $secret;
14
15
    /**
16
     * CredentialsOptions constructor.
17
     * @param array $options
18
     */
19
    public function __construct(array $options = [])
20
    {
21
        if (!empty($options)) {
22
            if (isset($options['key']) && isset($options['secret'])) {
23
                $this->key = $options['key'];
24
                $this->secret = $options['secret'];
25
            } else {
26
                throw new RuntimeException('Need to setup array[\'key\'=>\'\',\'secret\'=>\'\']');
27
            }
28
        }
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function getKey()
35
    {
36
        if (!$this->key) {
37
            throw new RuntimeException('Need setup `key` to credentials');
38
        }
39
        return $this->key;
40
    }
41
42
    /**
43
     * @param string $key
44
     * @return CredentialsOptions
45
     */
46
    public function setKey($key)
47
    {
48
        $this->key = $key;
49
        return $this;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getSecret()
56
    {
57
        if (!$this->key) {
58
            throw new RuntimeException('Need setup `secret` to credentials');
59
        }
60
        return $this->secret;
61
    }
62
63
    /**
64
     * @param string $secret
65
     * @return CredentialsOptions
66
     */
67
    public function setSecret($secret)
68
    {
69
        $this->secret = $secret;
70
        return $this;
71
    }
72
}
73