Parser   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 14 1
1
<?php
2
3
namespace Jalle19\CertificateParser;
4
5
use AcmePhp\Ssl\Certificate;
6
use AcmePhp\Ssl\Exception\CertificateParsingException;
7
use AcmePhp\Ssl\Parser\CertificateParser;
8
use Jalle19\CertificateParser\Provider\Exception\ProviderException;
9
use Jalle19\CertificateParser\Provider\ProviderInterface;
10
11
/**
12
 * Class Parser
13
 * @package Jalle19\CertificateParser
14
 */
15
class Parser
16
{
17
18
    /**
19
     * Attempts to parse the certificate using the specified provider
20
     *
21
     * @param ProviderInterface $provider
22
     *
23
     * @throws CertificateParsingException
24
     * @throws ProviderException
25
     *
26
     * @return ParserResults
27
     */
28
    public function parse(ProviderInterface $provider)
29
    {
30
        $parser = new CertificateParser();
31
32
        // Store the raw (array format) certificate, the PEM string and the parsed certificate in the results
33
        $rawCertificate = $provider->getRawCertificate();
34
        openssl_x509_export($rawCertificate, $pemString);
35
        $parsedCertificate = $parser->parse(new Certificate($pemString));
36
37
        return new ParserResults($parsedCertificate,
38
            openssl_x509_parse($rawCertificate),
39
            $pemString,
40
            openssl_x509_fingerprint($pemString));
41
    }
42
43
}
44