<?php

namespace Fifa\ConnectId\Sdk\MessageHandlers;

use Fifa\ConnectId\Sdk\Exception\XmlDeserializationException;
use Fifa\ConnectId\Sdk\Registration\ValidationException;
use Fifa\ConnectServiceBus\Sdk\Message\Message;

interface  MessageHandlerInterface
{
    /**
     * Checks if handler can handle message of a given message type
     * @param string|null $messageType - message type of the message to handle
     * @return bool - true if message type is supported by handler, otherwise false
     */
    public function canHandle(?string $messageType): bool;

    /**
     * Runs internal handler logic
     * @param string|null $messageType - message type of the message
     * @param Message $message - content of the message
     * @return void
     * @throws XmlDeserializationException
     * @throws ValidationException
     */
    public function handle(?string $messageType, Message $message);
}