<?php
namespace App\Amadeus\FileParser;

/**
 * @see MAIL:[AMA] split files, without SPT.
 * It seems that this line is pretty much useless
 */


class Line_SPT extends \App\Amadeus\FileParser\LineAbstract
{
	/**
	 * see page 120
	 * 4.24. SPT Split Party Reference Line
	 *
	 * To transmit cross referencing record locators for split party parent and child record locators.
	 */
	protected $structure = [
		['name'=> 'MSGTAG',     'val' => 'SPT',   'type' => 'AN',   'req' => 'M',  'len' => 3,],                    // 1 : Message Tag (SPT)
		['name' => 'PARCHD',                      'type' =>'composite',            'rep_min' =>0, 'rep_max' =>98,   // 2 Parent Child Record Locator Cross Reference. This is a composite element
		 'childs' => [
		   ['name'=> 'XRLOC',                     'type' => 'AN',                  'len' => 6,],                    // 3 : Cross Reference Record Locator.
		   ['name'=> 'DELIM',   'val' => ';',     'type' => 'AN',   'req' => 'M',  'len' => 1,],                    // 4 : Delimiter. (Constant value of ';'). No Delimiter follows the last XRLOC
		 ]
		]
	];

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

		if($this->tree['PARCHD']){
			$this->tree['PARCHD'] = self::rtrimArrDeep($this->tree['PARCHD'], 1);
		}
	}
}
