71 throw new Exception();
73 $arParsedOptions =
array();
75 foreach ($arParseParams as $paramName => $arParamData)
78 if ($arParamData[
'mandatory'])
80 if ( ! array_key_exists($paramName,
$arOptions) )
81 throw new Exception();
85 if ( ! array_key_exists($paramName,
$arOptions) )
87 if (array_key_exists(
'default_value', $arParamData))
88 $arOptions[$paramName] = $arParamData[
'default_value'];
93 switch ($arParamData[
'type'])
97 throw new Exception();
102 throw new Exception();
107 throw new Exception();
110 case 'strictly_castable_to_integer':
112 throw new Exception();
115 throw new Exception();
121 throw new Exception();
125 $arParsedOptions[$paramName] =
$arOptions[$paramName];
131 throw new Exception(
'there is unprocessed options');
133 return ($arParsedOptions);
138 if ( ! is_array($arParseParams) )
139 throw new Exception();
141 $arMandatoryFields =
array (
142 'type' =>
array(
'boolean',
'integer',
'strictly_castable_to_integer',
'string'),
143 'mandatory' =>
array(
true,
false)
146 foreach ($arParseParams as
$key => $element)
148 if ( ! is_array($element) )
149 throw new Exception();
152 foreach ($arMandatoryFields as $mandatoryField => $mandatoryFieldAllowedValues)
154 if ( ! array_key_exists($mandatoryField, $element) )
155 throw new Exception();
158 if (is_array($mandatoryFieldAllowedValues))
159 if ( ! in_array($element[$mandatoryField], $mandatoryFieldAllowedValues,
true) )
160 throw new Exception();
165 if (array_key_exists(
'default_value', $element) && ($element[
'mandatory'] !==
false))
166 throw new Exception(
'"default_value" incompatibily with enabled "mandatory" flag');