private function validateUid($uid)
    {
        if (!is_string($uid)) {
            throw new TokenException(sprintf('The uid must be a string, %s given.', gettype($uid)));
        }

        $uidSize = mb_strlen($uid, '8bit');

        if ($uidSize > static::MAX_UID_SIZE) {
            throw new TokenException(
                sprintf('The provided uid is longer than %d bytes (%d).', static::MAX_UID_SIZE, $uidSize)
            );
        }

        if (0 === $uidSize) {
            throw new TokenException('The provided uid is empty.');
        }
    }