LocalFileProvider::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Jalle19\CertificateParser\Provider;
4
5
use Jalle19\CertificateParser\Provider\Exception\FileNotFoundException;
6
7
/**
8
 * Class LocalFileProvider
9
 * @package Jalle19\CertificateParser\Provider
10
 */
11
class LocalFileProvider implements ProviderInterface
12
{
13
14
    /**
15
     * @var string
16
     */
17
    private $filePath;
18
19
20
    /**
21
     * LocalFileProvider constructor.
22
     *
23
     * @param string $filePath
24
     *
25
     * @throws FileNotFoundException if the file doesn't exist
26
     */
27
    public function __construct($filePath)
28
    {
29
        if (!file_exists($filePath)) {
30
            throw new FileNotFoundException($filePath . ' does not exist or is not readable');
31
        }
32
33
        $this->filePath = $filePath;
34
    }
35
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function getRawCertificate()
41
    {
42
        return openssl_x509_read(file_get_contents($this->filePath));
43
    }
44
45
}
46