private function getPEM(JWKInterface $key) { switch ($key->get('kty')) { case 'RSA': return (new RSAKey($key))->toPEM(); case 'EC': return (new ECKey($key))->toPEM(); default: throw new \InvalidArgumentException('Unsupported key type.'); } }