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

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

	protected $children = [
		/**
		 * This record contains data to be printed in the "Endorsements/Restrictions" box of the ticket
		 */

		[ 'key'=> 'key',                               'type'=> 'Constant',          'len'=> 1,         'val'=> 'E',   'req'=> true, ],        // Record identifier
		[ 'key'=> 'EndorsementRestrictionInformation', 'type'=> 'StringRaw',         'len'=> [0, 147],                 'req'=> true, ],             // Endorsement/Restriction information FOR CHGS/TK/VALID ONLY ON TW
	];

	protected function postExtract(\App\Utils\BaseParser\TextParser\ExtractedBlock $ret)
	{
		if ($ret->extractedData['EndorsementRestrictionInformation']) {
			$ret->extractedData['EndorsementRestrictionInformation_'] = array_filter(explode("//", $ret->extractedData['EndorsementRestrictionInformation']));
		}

		return $ret;
	}
}
