Completed
Push — master ( 1de13c...bf55ce )
by Alex
33:38
created

CryptKey::getPassPhrase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Cryptography key holder.
4
 *
5
 * @author      Julián Gutiérrez <[email protected]>
6
 * @copyright   Copyright (c) Alex Bilbie
7
 * @license     http://mit-license.org/
8
 *
9
 * @link        https://github.com/thephpleague/oauth2-server
10
 */
11
namespace League\OAuth2\Server;
12
13
class CryptKey
14
{
15
    /**
16
     * @var string
17
     */
18
    protected $keyPath;
19
20
    /**
21
     * @var string
22
     */
23
    protected $passPhrase;
24
25
    /**
26
     * @param string      $keyPath
27
     * @param null|string $passPhrase
28
     */
29
    public function __construct($keyPath, $passPhrase = null)
30
    {
31
        if (strpos($keyPath, 'file://') !== 0) {
32
            $keyPath = 'file://' . $keyPath;
33
        }
34
35
        if (!file_exists($keyPath) || !is_readable($keyPath)) {
36
            throw new \LogicException(sprintf('Key path "%s" does not exist or is not readable', $keyPath));
37
        }
38
39
        $this->keyPath = $keyPath;
40
        $this->passPhrase = $passPhrase;
41
    }
42
43
    /**
44
     * Retrieve key path.
45
     *
46
     * @return string
47
     */
48
    public function getKeyPath()
49
    {
50
        return $this->keyPath;
51
    }
52
53
    /**
54
     * Retrieve key pass phrase.
55
     *
56
     * @return null|string
57
     */
58
    public function getPassPhrase()
59
    {
60
        return $this->passPhrase;
61
    }
62
}
63