<?php
namespace App\Amadeus\FileParser;

class Line_TFC extends \App\Amadeus\FileParser\LineAbstract
{
	/**
	 * 4.117. TFC: Transaction Fee Counters
	 * see page 301(343)
	 *
	 * This line item is used to transmit Transaction Counters from an active TSF, for a passenger or for a Group.
	 */
	protected $structure = [
		['name'=> 'MSGTAG',     'val' => 'TFC',   'type' => 'AN',   'req' => 'M',  'len' => 3,],                          // 1 : Message Tag (TFC)
		['name'=> 'DELIM',      'val' => ';',     'type' => 'AN',   'req' => 'M',  'len' => 1,],                          // 2 : Delimiter (Constant value of ';')
		['name' => 'TCINFO',                      'type' =>'composite',            'rep_min' =>1,    'rep_max' =>150,     // 3 One element of the composite is composed of a tag, a delimiter (-) and a value.The data presence in the composite is conditioned by a TCVAL value which is not null...
		 'childs' => [
// 		   Array( 'name'=> 'TCTAG',                     'type' => 'AN',   'req' => 'M',  'len_min' => 2,   'len_max' => 4,),    // 4 : Value to be taken in the list of possible TCTAG (below this table).
// 		   Array( 'name'=> 'TCAUTOMAN',                 'type' => 'AN',   'req' => 'M',  'len' => 1,),                          // 5 : Indicator stating if the TCVAL parameter is the result of the process calculation (TCAUTOMAN takes value "-" for Automatic) or if it has been manually updated (TCAUTOMAN takes value "M" for Manual).
// 		   Array( 'name'=> 'TCVAL',                     'type' => 'AN',   'req' => 'M',),                                       // 6 : Transaction Counter value
           ['name'=> 'fld',                       'type' => 'AN',],
		   ['name'=> 'DELIM',   'val' => '+',     'type' => 'AN',                  'len' => 1,],                          // 7 : Delimiter (Constant value of '+')
		 ]],                                                                                                                     // 8
	];


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

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