<?php
namespace App\Sabre\LineParser\Types;

class SabreBaseLineMultipleFormats extends SabreBaseLine
{
	protected function _extractFromChildren($children, \App\Utils\BaseParser\TextParser\ExtractedBlock $ret, $rawData)
	{
		try {
			$ch = $children;
			$key = 		$ch['key'];
			$subkey = 	($ch['subkey']?:'0');
			$desc = 	$ch['description'];

			unset($ch['key']);
			unset($ch['subkey']);
			unset($ch['description']);

			\Engine\Debug\ParserCallTrace\ParserCallTrace::getInstance()->dlog("Trying {$key} ({$desc})");
			$this->children = $ch;
			$ret = parent::_extract($ret, $rawData);

			$ret->extractedData['type_'] = $key;
			$ret->extractedData['typeWithSubkey_'] = sprintf("%d.%d", $key, $subkey);
			$ret->extractedData['desc_'] = $desc;

			return $key;
		}
		catch (\App\Utils\BaseParser\TextParser\Exception\MissingRequiredElementException $ex) {
			// try next version
			\Engine\Debug\ParserCallTrace\ParserCallTrace::getInstance()->logCallEnd();
			\Engine\Debug\ParserCallTrace\ParserCallTrace::getInstance()->logCallEnd();
			return false;
		}
	}
}
