<?php
namespace App\Bsp\HotUA\Lines\Header;

/**
 * Line parser
 * @author Lucian Sirbu
 */
class BFH01 extends \App\Bsp\HotUA\HOTBase
{
	protected $children = [
		['key'=>'SMSG',  'type'=>'Constant', 'val'=>'BFH',       'len'=>3,      'label'=>'Standard Message Identifier'],    // S/M/Standard Message Identifier
		['key'=>'SQNR',  'type'=>'Integer',                      'len'=>8,      'label'=>'Sequence Number'],                // S/M/Sequence Number
		['key'=>'STNQ',  'type'=>'Constant', 'val'=>'01',        'len'=>2,      'label'=>'Standard Numeric Qualifier'],     // S/M/Standard Numeric Qualifier
		['key'=>'BSPI',  'type'=>'StringRaw',                    'len'=>3,      'label'=>'BSP Identifier'],                 // S/M/BSP Identifier
		['key'=>'TACN',  'type'=>'StringRaw',                    'len'=>3,      'label'=>'Ticketing Airline Code Number'],  // S/M/Ticketing Airline Code Number
		['key'=>'REVN',  'type'=>'Digits',                       'len'=>3,      'label'=>'Handbook Revision Number'],       // S/M/Handbook Revision Number
		['key'=>'TPST',  'type'=>'StringRaw',                    'len'=>4,      'label'=>'Test/Production Status'],         // S/M/Test/Production Status
		['key'=>'PRDA',  'type'=>'Date',     'fmt'=>'YYMMDD',    'len'=>6,      'label'=>'Processing Date'],                // S/M/Processing Date
		['key'=>'TIME',  'type'=>'Time',     'fmt'=>'HHMM',      'len'=>4,      'label'=>'Processing time'],                // S/M/Processing time
		['key'=>'ISOC',  'type'=>'Letters',                      'len'=>2,      'label'=>'ISO Country Code'],               // S/M/ISO Country Code
		['key'=>'FSQN',  'type'=>'Integer',                      'len'=>6,      'label'=>'File Sequence Number'],           // S/M/File Sequence Number
		['key'=>'RESD',  'type'=>'StringTrim',                   'len'=>92,     'label'=>'Reserved Space'],                 //  /M/Reserved Space
	];

	protected function postExtract(\App\Utils\BaseParser\TextParser\ExtractedBlock $ret)
	{
		if ($ret->extractedData['REVN']!='220') {
			throw new \App\Bsp\HotUA\Lines\Exception\General(sprintf("Don't know how to parse version %s of HOT files", $ret->extractedData['REVN']));
		}

		return $ret;
	}
}
