<?php
namespace App\Worldspan\LineParser\Types\Line; class R02 extends \App\Worldspan\LineParser\Types\WorldspanBaseLine { protected $extractRegexp = "/^(?P<rawData>(0|\*)2.+)/sm"; protected $children = [ ['key'=> 'RecordIdentifier', 'type'=> 'Set', 'len'=> 1, 'val'=> ['0', '*'], 'req'=> false,], ['key'=> '#015', 'type'=> 'Constant', 'len'=> 2, 'val'=> '2\\', 'req'=> true,], ['key'=> 'ItinerarySegmentNumber', 'type'=> 'Integer', 'len'=> [1, 3], 'req'=> true,], ['key'=> '#017', 'type'=> 'Separator', 'req'=> true,], ['key'=> 'NumberOfIntermediateStops', 'type'=> 'StringRaw', 'len'=> 1, 'req'=> true,], ['key'=> 'SharedDesignatorIndicator', 'type'=> 'StringRaw', 'len'=> 1, 'req'=> true,], ['key'=> 'CarrierCode', 'type'=> 'StringRaw', 'len'=> 2, 'req'=> true,], ['key'=> 'FlightNumber', 'type'=> 'StringDelimitedByChar', 'len'=> 4, 'val'=> '\\', 'req'=> true,], ['key'=> '#022', 'type'=> 'Separator', 'req'=> true,], ['key'=> 'ClassOfService', 'type'=> 'StringDelimitedByChar', 'len'=> [0, 2], 'val'=> '\\', 'req'=> true,], ['key'=> '#024', 'type'=> 'Separator', 'req'=> true,], ['key'=> 'OriginAirportCode', 'type'=> 'Alphanumeric', 'len'=> 3, 'req'=> true,], ['key'=> 'DepartureDate', 'type'=> 'Date', 'len'=> 5, 'fmt'=> 'DDMMM', 'req'=> true, 'ref'=>'BookingDateAndYear', 'onlyFuture'=>true,], ['key'=> 'DepartureTime', 'type'=> 'Time', 'len'=> 5, 'fmt'=> 'HHMMP+', 'req'=> true,], ['key'=> '#028', 'type'=> 'Separator', 'req'=> true,], ['key'=> 'DestinationAirportCode', 'type'=> 'Alphanumeric', 'len'=> 3, 'req'=> true,], ['key'=> 'ArrivalDate', 'type'=> 'Date', 'len'=> 5, 'fmt'=> 'DDMMM', 'req'=> true, 'ref'=>'BookingDateAndYear', 'onlyFuture'=>true,], ['key'=> 'ArrivalTime', 'type'=> 'Time', 'len'=> 5, 'fmt'=> 'HHMMP+', 'req'=> true,], ['key'=> '#033', 'type'=> 'Constant', 'len'=> 5, 'val'=> '\\*\\*\\', 'req'=> true,], ['key'=> 'complex:25', 'type'=> 'Complex', 'merge'=>true, 'req'=> true, 'children'=> [ ['key'=> '#037', 'type'=> 'Constant', 'len'=> 2, 'val'=> '*\\', 'req'=> true,], ['key'=> 'StatusCode', 'type'=> 'Alphanumeric', 'len'=> 2, 'req'=> false,], ['key'=> 'group#1', 'type'=> 'StringDelimitedByChar', 'len'=> [0, 43], 'val'=> '\\', 'req'=> true,], ['key'=> '#042', 'type'=> 'Separator', 'req'=> false,], ['key'=> 'EquipmentType', 'type'=> 'StringDelimitedByChar', 'len'=> [0, 3], 'val'=> '\\', 'req'=> false,], ]], ['key'=> '#044', 'type'=> 'Separator', 'req'=> false,], ['key'=> 'complex:27', 'type'=> 'Complex', 'merge'=>true, 'req'=> true, 'children'=> [ ['key'=> '#045', 'type'=> 'Constant', 'len'=> 2, 'val'=> '*\\', 'req'=> true,], ['key'=> 'SegmentMileage', 'type'=> 'StringDelimitedByChar', 'len'=> [1, 5], 'val'=> '\\', 'req'=> false,], ['key'=> '#048', 'type'=> 'Separator', 'req'=> false,], ['key'=> 'IntermediateStops', 'type'=> 'StringDelimitedByChar', 'len'=> [0, 159], 'val'=> '\\', 'req'=> false,], ['key'=> '#050', 'type'=> 'Separator', 'req'=> false,], ['key'=> 'AccumulatedElapsedFlightTime', 'type'=> 'FloatRaw', 'len'=> [1, 5], 'req'=> false,], ]], ['key'=> '#053', 'type'=> 'Set', 'len'=> 3, 'val'=> ['\\@\\', '\\*\\',], 'req'=> true,], ['key'=> 'DepartureAirportTerminalCode', 'type'=> 'StringDelimitedByChar', 'len'=> [0, 2], 'val'=> '\\', 'req'=> false,], ['key'=> '#056', 'type'=> 'Separator', 'req'=> false,], ['key'=> 'ArrivalAirportTerminalCode', 'type'=> 'StringDelimitedByChar', 'len'=> [0, 2], 'val'=> '\\', 'req'=> false,], ['key'=> '#x01', 'type'=> 'Separator', 'req'=> false,], ['key'=> 'unknown01', 'type'=> 'StringRaw', 'req'=> false,], ]; protected function postExtract(\App\Utils\BaseParser\TextParser\ExtractedBlock $ret) { unset($ret->extractedData['#053']); $ret->extractedData['AccumulatedElapsedFlightTime'] = sprintf("%s", str_replace(".", ":", sprintf("%.2f", $ret->extractedData['AccumulatedElapsedFlightTime']))); $ret->extractedData['SegmentMileage_'] = ($ret->extractedData['SegmentMileage']=='*'?null:(float)$ret->extractedData['SegmentMileage']); $ret->extractedData['MealServiceCodes'] = trim(substr($ret->extractedData['group#1'], 0, -1)); $ret->extractedData['StopoverCode'] = substr($ret->extractedData['group#1'], -1); unset($ret->extractedData['group#1']); return $ret; } } 