<?php
namespace App\Amadeus\FileParser;

class Line_N extends \App\Amadeus\FileParser\LineAbstract
{
	/**
	 * 4.88. N- Segment Fare
	 * see page 250(292)
	 *
	 * Each ticketed segment in the AIR is represented and separated by a delimiter.
	 */
	protected $structure = [
		['name'=> 'MSGTAG',     'val' => 'N-',    'type' => 'AN',   'req' => 'M',  'len' => 2,],                    // 1 : Message Tag (N-)
		['name'=> 'CURRTYP',                      'type' => 'AN',   'req' => 'M',  'len' => 3,],                    // 2 : Currency Type Code
		['name' => 'FARESEG',                     'type' =>'composite',            'rep_min' =>0, 'rep_max' =>28,   // 3 Fare Element (This is a composite element)
		 'childs' => [
		   ['name'=> 'BASE',                      'type' => 'AN',],                                 // 4 : Base Fare
		   ['name'=> 'DELIM',   'val' => ';',     'type' => 'AN',   'req' => 'M',  'len' => 1,],                    // 5 : Delimiter (Constant value of ';') No delimiter follows the last base fare)
		 ]]];


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

		if($this->tree['FARESEG']){
			$this->tree['FARESEG'] = self::rtrimArr($this->tree['FARESEG']);
		}
	}
}
