<?php

declare(strict_types=1);

namespace PhpWA\Crypto\Signal;

use InvalidArgumentException;
use PhpWA\Protocol\Jid\Jid;

final class SenderKeyName
{
    public static function compose(string $groupJid, string $senderJid): string
    {
        $group = Jid::parse($groupJid); $sender = Jid::parse($senderJid);
        if ($group === null || !$group->isGroup() || $sender === null || ($sender->isGroup() || $sender->isBroadcast())) { throw new InvalidArgumentException('Sender Key group or sender JID is invalid.'); }
        return (string) $group . '::' . (string) $sender;
    }
    private function __construct() {}
}
