<?php
namespace App\Worldspan\LineParser\Types\Line;

/**
 *
 * @author Lucian Sirbu
 */
class RV extends \App\Worldspan\LineParser\Types\WorldspanBaseLine
{
	protected $extractRegexp = "/^(?P<rawData>V.+)/sm";

	protected $children = [
        /**
         * This record contains "Trip Value" information
         * Much of the data uses the strict formatting of the vertical fare calculation
         * This formatting makes it easier for your back-office system to break down individual segment costs and taxes
         * Due to mandates by the United States government, PFC amount field lengths have been changed from a single numeric to 4 numerics
         */
        ['key'=> 'key',                               'type'=> 'Constant',                         'len'=> 2,     'val'=> 'V\\',                'req'=> true,],              // Record identifier
        ['key'=> 'bulk',                              'type'=> 'StringRaw',                                                                        'req'=> true,],

        /*
        Array(                'key'=> 'FCI',                               'type'=> 'Integer',                          'len'=> 1,                                   'req'=> true, ),              // FCI (see Note 3)
        Array(                'key'=> '#018',                              'type'=> 'Separator',                                                                     'req'=> true, ),              // Field separator
        Array(                'key'=> 'PTC',                               'type'=> 'StringRaw',                           'len'=> 3,                                   'req'=> true, ),             // Passenger Type Code (PTC)
        Array(                'key'=> '#020',                              'type'=> 'Separator',                                                                     'req'=> true, ),             // Field Separator
        Array(                'key'=> 'BlankOrLeftParen',                  'type'=> 'StringRaw',                           'len'=> 1,                                   'req'=> true, ),             // Blank or left paren "("
        Array(                'key'=> 'OriginAirportCityCode',             'type'=> 'StringRaw',                           'len'=> 3,                                   'req'=> true, ),             // Origin Airport/City code (see Note 4)
        Array(                'key'=> 'BlankOrRightParen',                 'type'=> 'StringDelimitedByChar',            'len'=> 1,     'val'=> '\\',                 'req'=> true, ),             // Blank or right paren ")" Trip Values (Minimum 1)


		Array(                'key'=> 'legs',                                                                            'rep'=>Array(50, 50),                         'req'=> true, 'children'=> Array(
			Array(            'key'=> 'segment',                           'type'=> 'Complex',                                                                        'req'=> false, 'children'=> Array(
				Array(            'key'=> '_type',                               'type'=> 'InternalMarker',                            'val'=>'Multiple Leg Trip', ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> '\\',                  'req'=> true, ),
				Array(            'key'=> 'departureAirport',                    'type'=> 'Letters',           'len'=> 3,                                   'req'=> true, ),
				Array(            'key'=> 'departureAirline',                    'type'=> 'Letters',           'len'=> 2,                                   'req'=> true, ),
				Array(            'key'=> 'stopOver',                            'type'=> 'Set',               'len'=> 1,    'val'=> Array(' ', 'X',),      'req'=> true, ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 2,    'val'=> '  ',                  'req'=> true, ),
				Array(            'key'=> 'excessMileageIndicator',              'type'=> 'StringRaw',            'len'=> 2,                                   'req'=> true, ),
				Array(            'key'=> 'typeOffareIndicator',                 'type'=> 'Set',               'len'=> 1,    'val'=> Array(' ', 'M',),      'req'=> true, ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> ' ',                   'req'=> true, ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> '\\',                  'req'=> true, ),
				Array(            'key'=> 'arrivalAirport',                      'type'=> 'Letters',           'len'=> 3,                                   'req'=> true, ),
				Array(            'key'=> 'arrivalAirline',                      'type'=> 'Letters',           'len'=> 2,                                   'req'=> true, ),
				Array(            'key'=> 'tripValue',                           'type'=> 'Amount',            'len'=> 6,                                   'req'=> true, ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> ' ',                   'req'=> true, ),
			)),

			Array(            'key'=> 'segment',                           'type'=> 'Complex',                                                                        'req'=> false, 'children'=> Array(
				Array(            'key'=> '_type',                               'type'=> 'InternalMarker',                            'val'=>'Security Charge', ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> '\\',                  'req'=> true, ),
				Array(            'key'=> 'firstAirport',                        'type'=> 'Letters',           'len'=> 3,                                   'req'=> true, ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 2,    'val'=> ' X',                  'req'=> true, ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 7,    'val'=> '       ',             'req'=> true, ),
				Array(            'key'=> 's01',                                 'type'=> 'Complex',                                                            'req'=> true, 'children'=> Array(
					Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> '\\',                  'req'=> true, ),
					Array(            'key'=> 'secondAirport',                       'type'=> 'Letters',           'len'=> 3,                                   'req'=> true, ),
					Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 2,    'val'=> ' Q',                  'req'=> true, ),
					Array(            'key'=> 'tripValue',                           'type'=> 'Amount',            'len'=> 6,                                   'req'=> true, ),
					Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> ' ',                   'req'=> true, ),
				)),
				Array(            'key'=> 's02',                                 'type'=> 'Complex',                                                            'req'=> false, 'children'=> Array(
					Array(            'key'=> 'ct02',                                'type'=> 'Constant',          'len'=> 1,    'val'=> '\\',                  'req'=> true, ),
					Array(            'key'=> 'secondAirport02',                     'type'=> 'Letters',           'len'=> 3,                                   'req'=> true, ),
					Array(            'key'=> 'ct02',                                'type'=> 'Constant',          'len'=> 2,    'val'=> ' Q',                  'req'=> true, ),
					Array(            'key'=> 'tripValue02',                         'type'=> 'Amount',            'len'=> 6,                                   'req'=> true, ),
					Array(            'key'=> 'ct02',                                'type'=> 'Constant',          'len'=> 1,    'val'=> ' ',                   'req'=> true, ),
				)),
			)),

			Array(            'key'=> 'segment',                           'type'=> 'Complex',                                                                        'req'=> false, 'children'=> Array(
				Array(            'key'=> '_type',                               'type'=> 'InternalMarker',                            'val'=>'One Leg Trip', ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> '\\',                  'req'=> true, ),
				Array(            'key'=> 'airport',                             'type'=> 'Letters',           'len'=> 3,                                   'req'=> true, ),
				Array(            'key'=> 'airline',                             'type'=> 'Letters',           'len'=> 2,                                   'req'=> true, ),
				Array(            'key'=> 'tripValue',                           'type'=> 'Amount',            'len'=> 6,                                   'req'=> true, ),
				Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 1,    'val'=> ' ',                   'req'=> true, ),
			)),



        )),

		Array(                'key'=> '#025',                              'type'=> 'Separator',                                                                     'req'=> true, ),
		Array(                'key'=> 'TotalTripValues',                   'type'=> 'Complex', 'merge'=>false,           'rep'=>Array(1, 1),                         'req'=> false, 'children'=> Array(
			Array(            'key'=> 'ct',                                  'type'=> 'Constant',          'len'=> 5,    'val'=> '  $  ',               'req'=> true, ),
			Array(            'key'=> 'tripInNUC',                           'type'=> 'StringRaw',            'len'=> 1,                                   'req'=> true, ),
			Array(            'key'=> 'amount',                              'type'=> 'Amount',            'len'=> 6,                                   'req'=> true, ),
		)),
		*/
	];
}
