<?php
namespace App\Sabre\StructureParser\Structures\Ticketing;

class Supplier extends \App\Sabre\StructureParser\Structures\Base\Supplier
{
	protected function _getData()
	{
		list($parsedStructure, $transactionType, $transactionIndexes, ) = $this->getTransactionDetails();

		$item = new \App\Sabre\StructureParser\Types\Supplier();

		if ($this->transaction->isTicketingIssue($parsedStructure, $transactionType, $transactionIndexes)) {
			if ($transactionIndexes['km5']!==null) {
				$item->codeAirline = $parsedStructure['M5'][$transactionIndexes['km5']]['validatingCarrierCode'];
			}
		}
		else {
			$processedRemarks = $this->transaction->remarks->getProcessedRemarks();
			$item->codeAirline = $processedRemarks['SUPPLIER'];
			$this->transaction->getMessagesCollector()->addInfo(sprintf("Supplier was loaded from remarks")); // TODO: [cleanMsgs-transactionGDSs] refactor this from GDSs
		}

		return $item;
	}
}
