Certificate   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 90
ccs 5
cts 20
cp 0.25
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getP12Certificate() 0 8 2
A getPassword() 0 8 2
A getPemCertificate() 0 8 2
A getPemCertificatePath() 0 4 1
A setPaths() 0 6 1
1
<?php
2
3
namespace Notimatica\Driver\Apns;
4
5
use League\Flysystem\Filesystem;
6
use Notimatica\Driver\Project;
7
8
class Certificate
9
{
10
    /**
11
     * @var Filesystem
12
     */
13
    protected $storage;
14
    /**
15
     * @var array
16
     */
17
    protected $paths = [
18
        'p12'       => 'certificate.p12',
19
        'pem'       => 'certificate.pem',
20
        'password'  => 'certificate.password',
21
    ];
22
23
    /**
24
     * Create a new Certificate.
25
     *
26
     * @param Filesystem $storage
27
     */
28 1
    public function __construct(Filesystem $storage)
29
    {
30 1
        $this->storage = $storage;
31 1
    }
32
33
    /**
34
     * Return certificate.
35
     *
36
     * @return string
37
     */
38
    public function getP12Certificate()
39
    {
40
        try {
41
            return $this->storage->get($this->paths['p12']);
42
        } catch (\Exception $e) {
43
            return '';
44
        }
45
    }
46
47
    /**
48
     * Return password.
49
     *
50
     * @return string
51
     */
52
    public function getPassword()
53
    {
54
        try {
55
            return $this->storage->get($this->paths['password']);
56
        } catch (\Exception $e) {
57
            return '';
58
        }
59
    }
60
61
    /**
62
     * Get pem certificate.
63
     *
64
     * @return string
65
     */
66
    public function getPemCertificate()
67
    {
68
        try {
69
            return $this->storage->get($this->paths['pem']);
70
        } catch (\Exception $e) {
71
            return '';
72
        }
73
    }
74
75
    /**
76
     * Return pem certificate path.
77
     *
78
     * @return string
79
     */
80 1
    public function getPemCertificatePath()
81
    {
82 1
        return $this->storage->getAdapter()->applyPathPrefix($this->paths['pem']);
83
    }
84
85
    /**
86
     * Set certificates filenames.
87
     *
88
     * @param  array $paths
89
     * @return $this
90
     */
91
    public function setPaths(array $paths)
92
    {
93
        $this->paths = $paths;
94
95
        return $this;
96
    }
97
}
98