<?php
namespace App\Amadeus\FileParser;

class Line_A extends \App\Amadeus\FileParser\LineAbstract
{
	/**
	 * 4.14.A- Validating Carrier
	 * see page 77
	 *
	 * To identify the carrier that the ticket is to be validated on. If the validating carrier is not present, the MSGTAG field will be followed immediately by the Carriage Return.
	 */
	protected $structure = [
		['name'=> 'MSGTAG',  'val' => 'A-',    'type' => 'AN',   'req' => 'M',  'len' => 2,],  // 1 : Message Tag (A-).
		['name'=> 'end',                       'type' => 'end',],
		['name'=> 'TKTAIR',                    'type' => 'AN',   'req' => 'M',],               // 2 : Ticketing Airline Name
		['name'=> 'DELIM',   'val' => ';',     'type' => 'AN',   'req' => 'M',  'len' => 1,],  // 3 : Delimiter (Constant value of ';')
		['name'=> 'ALCDE',                     'type' => 'AN',   'req' => 'M',  'len' => 3,],  // 4 : Airline Code
		['name'=> 'NUMCDE',                    'type' => 'N',    'req' => 'M',  'len' => 3,],  // 5 : Airline Numeric Code (including check digit) or UIC Code
		['name'=> 'NUMCDE_checkDigit',         'type' => 'N',    'req' => 'M',  'len' => 1,],  //
		['name'=> 'TKTMOD',                    'type' => 'AN',                  'len' => 3,],  // 6 : Ticketing Issuance Mode (empty for CTS standard, LCC for low-cost, CNS for consolidator) For a detailed description of the above fields, see Carrier Selection A02TKT3507.Ref.No NAME RequirementDesignator TypeLengthIteration Description.
	];

	/**
	 * (non-PHPdoc)
	 * @see \App\Amadeus\FileParser\LineAbstract::postParse()
	 */
	protected function postParse()
	{
		// call the parent first
		parent::postParse();

		if($this->tree['ALCDE']){
			$this->tree['ALCDE'] = rtrim($this->tree['ALCDE']);
		}
	}
}
