PublicKey::createKey()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 2
rs 10
1
<?php
2
3
/**
4
 * This file is part of the Pixidos package.
5
 *
6
 *  (c) Ondra Votava <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 *
11
 */
12
13
declare(strict_types=1);
14
15
namespace Pixidos\GPWebPay\Signer\Key;
16
17
use OpenSSLAsymmetricKey;
18
use Pixidos\GPWebPay\Exceptions\SignerException;
19
20
class PublicKey extends AbstractKey
21
{
22
    /**
23
     * @throws SignerException
24
     */
25 15
    protected function createKey(): OpenSSLAsymmetricKey
26
    {
27 15
        $key = openssl_pkey_get_public($this->getContent());
28 15
        if (false === $key) {
29 1
            throw new SignerException(
30 1
                sprintf('"%s" is not valid public key.', $this->file)
31 1
            );
32
        }
33
34 14
        return $this->key = $key;
35
    }
36
}
37