<?php

namespace iDServer\Message;

use DomainException;

class MessageType
{
    const LOGIN = "Login";
    const LOGIN_REPLY = "LoginReply";
    const LOGOUT = "Logout";
    const LOGOUT_REPLY = "LogoutReply";
    const NAME_ID_MAPPING = "NameIDMapping";
    const NAME_ID_MAPPING_RESPONSE = "NameIdMappingResponse";
    const ATTRIBUTE_QUERY = "AttributeQuery";
    const ATTRIBUTE_QUERY_RESPONSE = "AttributeQueryResponse";

    /**
     * Get the response type which belongs the passed request type
     *
     * @param string $type Request type
     * @return string
     */
    public static function ofReplyFor($type)
    {
        switch ($type) {
            case MessageType::LOGIN:
                return MessageType::LOGIN_REPLY;
            case MessageType::LOGOUT:
                return MessageType::LOGOUT_REPLY;
            default:
                throw new DomainException("No reply type defined for " . $type);
        }
    }
}
