| Total Complexity | 3 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 12 | class PemPublicKeySerializer implements PublicKeySerializerInterface |
||
| 13 | { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var DerPublicKeySerializer |
||
| 17 | */ |
||
| 18 | private $derSerializer; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param DerPublicKeySerializer $serializer |
||
| 22 | */ |
||
| 23 | public function __construct(DerPublicKeySerializer $serializer) |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * {@inheritDoc} |
||
| 30 | * @see \Mdanter\Ecc\Serializer\PublicKey\PublicKeySerializerInterface::serialize() |
||
| 31 | */ |
||
| 32 | public function serialize(PublicKeyInterface $key): string |
||
| 33 | { |
||
| 34 | $publicKeyInfo = $this->derSerializer->serialize($key); |
||
| 35 | |||
| 36 | $content = '-----BEGIN PUBLIC KEY-----'.PHP_EOL; |
||
| 37 | $content .= trim(chunk_split(base64_encode($publicKeyInfo), 64, PHP_EOL)).PHP_EOL; |
||
| 38 | $content .= '-----END PUBLIC KEY-----'; |
||
| 39 | |||
| 40 | return $content; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritDoc} |
||
| 45 | * @see \Mdanter\Ecc\Serializer\PublicKey\PublicKeySerializerInterface::parse() |
||
| 46 | */ |
||
| 47 | public function parse(string $formattedKey): PublicKeyInterface |
||
| 55 | } |
||
| 56 | } |
||
| 57 |