We can use Repository \Magento\InventoryApi\Api\SourceRepositoryInterface to get the source by code
when we have a source code with us if we want to get the source name we may call a block function to load the source name with the source Id
Block Code
constructor:
\Magento\InventoryApi\Api\SourceRepositoryInterface $sourceRepository
$this->sourceRepository = $sourceRepository;
-------------------------------------------------------------------------
public function getSourceName($sourceCode)
{
$sourceData = $this->sourceRepository->get($sourceCode);
$sourename = $sourceData->getName();
return $sourename;
}
Phtml File
$sourename = $dealerData->getSourceName($sourceCode); ?>
<span>WareHouse : <span class="method"><?= $sourename."<br>";?></span></span>