GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

KeyManager::getContent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Gandung\JWT\Manager;
4
5
use Gandung\Psr7\FileStream;
6
7
/**
8
 * @author Paulus Gandung Prakosa <[email protected]>
9
 */
10
class KeyManager implements KeyManagerInterface
11
{
12
    /**
13
     * @var string
14
     */
15
    private $content;
16
17
    /**
18
     * @var string
19
     */
20
    private $passphrase;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function setContent($content)
26
    {
27
        $this->content = $content;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getContent()
34
    {
35
        return $this->content;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function setContentFromCertFile($file)
42
    {
43
        $file = $this->stripProtocolNameFromCertFile($file);
44
45
        if (!file_exists($file)) {
46
            throw new \InvalidArgumentException(
47
                sprintf("Certificate file named '%s' not exists.", $file)
48
            );
49
        }
50
51
        $stream = new FileStream($file, 'rb');
52
        $this->setContent($stream->getContents());
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function setPassphrase($passphrase = '')
59
    {
60
        $this->passphrase = $passphrase;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getPassphrase()
67
    {
68
        return $this->passphrase;
69
    }
70
71
    /**
72
     * Strip 'file://' from given filename.
73
     *
74
     * @param string $file
75
     * @return string
76
     */
77
    private function stripProtocolNameFromCertFile($file)
78
    {
79
        return false === strpos($file, 'file://')
80
            ? $file
81
            : str_replace('file://', '', $file);
82
    }
83
}
84