Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Lines | 14 |
Ratio | 100 % |
Tests | 8 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
33 | 5 | public function __construct(string $publicKeyOrPath) |
|
34 | { |
||
35 | 5 | assert( |
|
36 | 5 | $this->checkIfPathToFileCheckPrefix($publicKeyOrPath), |
|
37 | 5 | 'It seems you try to use path to file. If so you should prefix it with \'file://\'.' |
|
38 | ); |
||
39 | |||
40 | 5 | $this->clearErrors(); |
|
41 | |||
42 | 5 | $publicKey = openssl_pkey_get_public($publicKeyOrPath); |
|
43 | 5 | $publicKey !== false ?: $this->throwException(new CryptException($this->getErrorMessage())); |
|
44 | |||
45 | 5 | $this->setKey($publicKey); |
|
46 | } |
||
47 | } |
||
48 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.