Completed
Push — master ( 4e360d...80bc96 )
by Daan van
07:27
created

PrivateKey   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 71
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 18 5
A getFilePath() 0 4 1
A hasPassPhrase() 0 4 1
A getPassPhrase() 0 4 1
A getName() 0 4 1
1
<?php
2
3
namespace SAML2\Configuration;
4
5
use SAML2\Exception\InvalidArgumentException;
6
7
/**
8
 * Configuration of a private key.
9
 */
10
class PrivateKey extends ArrayAdapter
11
{
12
    const NAME_NEW     = 'new';
13
    const NAME_DEFAULT = 'default';
14
15
    /**
16
     * @var string
17
     */
18
    private $filePath;
19
20
    /**
21
     * @var string
22
     */
23
    private $passphrase;
24
25
    /**
26
     * @var string
27
     */
28
    private $name;
29
30
    public function __construct($filePath, $name, $passphrase = null)
31
    {
32
        if (!is_string($filePath)) {
33
            throw InvalidArgumentException::invalidType('string', $filePath);
34
        }
35
36
        if (!is_string($name)) {
37
            throw InvalidArgumentException::invalidType('string', $name);
38
        }
39
40
        if ($passphrase && !is_string($passphrase)) {
41
            throw InvalidArgumentException::invalidType('string', $passphrase);
42
        }
43
44
        $this->filePath = $filePath;
45
        $this->passphrase = $passphrase;
46
        $this->name = $name;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getFilePath()
53
    {
54
        return $this->filePath;
55
    }
56
57
    /**
58
     * @return bool
59
     */
60
    public function hasPassPhrase()
61
    {
62
        return (bool) $this->passphrase;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getPassPhrase()
69
    {
70
        return $this->passphrase;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getName()
77
    {
78
        return $this->name;
79
    }
80
}
81