<?php
namespace App\Galileo\NDCLineParser\Types;

/**
 * Data line
 * @author Lucian Sirbu
 */
class Data_PassengerTaxBreakdown extends \App\Galileo\LineParser\Types\GalileoBase
{
	protected $extractRegexp = "/^(?P<rawData>FT-#TAS[0-9]+#P[0-9]+[A-Z]{3}\/([A-Z][A-Z0-9])[0-9\.]+(\/([A-Z][A-Z0-9])[0-9\.]+)*)/";
	protected $useCustomRegexp = true;

	/**
	 * Children elements
	 */
	protected $children = [
		[ 'key'=>'FT',  	                     'type'=>'Constant',        			 'val'=> 'FT-',                           'label'=>'DOCI-FREETEXT-#' ],
		[ 'key'=>'TAS',                          'type'=>'Constant',                     'val'=> '#TAS', ],
		[ 'key'=>'fareNumber',                   'type'=>'Integer',           'len'=>2, ],
		[ 'key'=>'separator',                    'type'=>'Constant',                     'val'=> '#', ],

		[ 'key'=>'P',                            'type'=>'Constant',                     'val'=> 'P', ],
		[ 'key'=>'passengerIdentifier',          'type'=>'Integer',        'len'=>2, ],
		[ 'key'=>'passengerTypeCode',            'type'=>'StringTrim',     'len'=>3, ],

		[ 'key'=>'taxes',        'startsWith'=>'Constant', 'val'=> '/',  'rep'=>[0, PHP_INT_MAX], 'greedy'=>true,  'req'=>true,  'children'=> [
			[ 'key'=>'separator',                    'type'=>'Constant',                     'val'=> '/', ],
			[ 'key'=>'code',                         'type'=>'StringTrim', 'len'=>2, ],
			[ 'key'=>'amount',                       'type'=>'Price', ],
		]],

	];
}
