<?php
namespace App\Sabre\StructureParser\Structures\Hotel;

class Passengers extends \App\Sabre\StructureParser\Structures\Base\Passengers
{
	protected function _getData()
	{
		list($parsedStructure, , $transactionIndexes) = $this->getTransactionDetails();

		$passengers = new \App\Sabre\StructureParser\Types\Passengers();

		foreach ($transactionIndexes['km1s'] as $km1) {
			$item = new \App\Sabre\StructureParser\Types\Passenger();

			$M1 = $parsedStructure['M1'][$km1];
			$M2 = $parsedStructure['M2'][$km1];

			$item->firstName = 	$M1['M1']['IU1PNM_']['firstname'];
			$item->lastName = 	$M1['M1']['IU1PNM_']['lastname'];
			$item->title = 		$M1['M1']['IU1PNM_']['title'];
			$item->type = 		($M2['M2']['IU2PTY_']['type']?:'adult');

			$passengers->append($item);
		}

		return $passengers;
	}
}
