How to get payment method title of an order in magento 2?

Get Payment Method title from the Order details in Magento 2 by order repository interface.

Load an Order by API OrderRepositoryInterface with Order id, Get Payment Object, fetch Payment related stuff from the Payment Data.

You can get payment method title of an order by below code snippets,

<?php
namespace Rbj\Training\Helper;

class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
    public function __construct(
        \Magento\Framework\App\Helper\Context $context,
        \Magento\Sales\Api\OrderRepositoryInterface $orderRepository

    ) {
        $this->orderRepository = $orderRepository;
        parent::__construct($context);
    }

    /**
     * @inheritdoc
     */
    public function getPaymentData()
    {
        $orderId = 1;
        $order = $this->orderRepository->get($orderId);
        $payment = $order->getPayment();
        $method = $payment->getMethodInstance();
        echo $method->getTitle(); // Cash On Delivery
        echo $method->getCode(); // cashondelivery
    }

}