@param array $result
@param string $option
@param string $value

@return array
775055
private function updateParseResult(array $result, string $option, string $value) : array
    {
        $option_type = $this->options[$option]['type'] ?? self::OPTION_TYPE_OPTIONAL;
        if ($option_type === self::OPTION_TYPE_MULTIPLE){
            $result['named'][$option][] = $value;
        }
        else{
            $result['named'][$option] = $value;
        }
        return $result;
    }
242961
public function serialize($value, array $options=[])
    {

        $serialized = json_encode(
            $value,
            $this->bitmask($options),
            $this->getDepth($options)
        );

        return $serialized;

    }
1374939
public function select_option($values, $selected_value) {
		$content = '';

		foreach ($values as $value => $title) {
			if (is_array($title)) {
				$label		= $this->_escape($value);
				$content	.= "<optgroup label=\"{$label}\">";
				$content	.= $this->select_option($title, $selected_value);
				$content	.= "</optgroup>";
			} else {
				$value		= $this->_escape($value);
				$title		= $this->_escape($title);

				$selected = '';
				if (is_scalar($selected_value) && $value == $selected_value) {
					$selected = ' selected="selected"';
				} elseif (is_array($selected_value) && in_array($value, $selected_value)) {
					$selected = ' selected="selected"';
				}

				$content	.= "<option value=\"{$value}\"{$selected}>{$title}</option>";
			}
		}

		return $content;
	}
67338
public static function prepareOptions($options, $blank_first_option = false, $name_first_option = '', $value_first_option = '')
    {
        $options = array_map(function ($key, $value) {
            return [$key, $value];
        }, array_keys($options), array_values($options));
        if ($blank_first_option) {
            array_unshift($options, [$value_first_option, $name_first_option]);
        }

        return $options;
    }
208542
private function getFinalValue(string $type, string $name, $value, bool $optionnal)
    {
        if ($optionnal && ($value === null || $value === '')) {
            return null;
        }

        if (strpos($type, '[]') !== false) {
            $return = [];
            foreach (is_array($value) ? $value : [$value] as $sKey => $currentValue) {
                $return[$sKey] = $this->getFinalValue(str_replace('[]', '', $type), $name, $currentValue, $optionnal);
            }

            return $return;
        }

        switch ($type) {
            case 'int':
                $value = filter_var($value, FILTER_VALIDATE_INT, ['flags' => FILTER_NULL_ON_FAILURE]);
                if (is_null($value)) {
                    throw new ResponseCode("Invalid integer parameters '$name' with value '$value'", 422);
                }

                break;

            case 'float':
                $value = filter_var($value, FILTER_VALIDATE_FLOAT, ['flags' => FILTER_NULL_ON_FAILURE]);
                if (is_null($value)) {
                    throw new ResponseCode("Invalid float parameters '$name' with value '$value'", 422);
                }

                break;

            case 'string':
                if (!is_string($value) || !$value) {
                    throw new ResponseCode("Invalid string parameters '$name' with value '$value'", 422);
                }
                break;

            case 'bool':
                if ($value !== '1' &&
                    $value !== 1 &&
                    $value !== '0' &&
                    $value !== 0 &&
                    $value !== 'true' &&
                    $value !== 'false'
                ) {
                    throw new ResponseCode("Invalid bool parameters '$name' with value '$value'", 422);
                }

                if ($value == '1') {
                    $value = true;
                } elseif ($value === 'true') {
                    $value = true;
                } elseif ($value == '0') {
                    $value = false;
                } elseif ($value === 'false') {
                    $value = false;
                }

                if (!is_bool($value)) {
                    throw new ResponseCode("Invalid bool parameters '$name' with value '$value'", 422);
                }
                break;

            case '\\Cawa\\SwaggerServer\\DateTime':
                $value = DateTime::createFromInput($value);
                break;

            case 'array':
                if (!is_array($value)) {
                    $jsonValue = @json_decode($value, true);

                    if ($jsonValue === false || !is_array($jsonValue)) {
                        throw new ResponseCode("Invalid array parameters '$name' with value '$value'", 422);
                    }

                    $value = $jsonValue;
                }
                break;

            case 'mixed':
                if (is_numeric($value)) {
                    $value = 0 + $value;
                }

                break;

            default:
                throw new \Exception('Invalid ' . $type . " parameters '$name' with value '$value'");
                break;
        }

        return $value;
    }
856638
public static function boolean($value, $options = null)
    {
        if (!is_null($options)) {
            $options = explode('|', $options);
        }

        if (sizeof($options) != 2) {
            $options = array('No', 'Yes');
        }

        return $options[!!$value];
    }
352549
public function filter($value, $options = [])
    {
        $value    = (string) $value;
        $filtered = htmlentities(
            $value,
            $this->getQuoteStyle(),
            $this->getEncoding(),
            $this->getDoubleQuote()
        );

        if (strlen($value) && !strlen($filtered)) {
            if (!function_exists('iconv')) {
                $ex = new \Exception('Encoding mismatch has resulted in htmlentities errors.');
                throw $ex;
            }

            $enc      = $this->getEncoding();
            $value    = iconv('', $enc . '//IGNORE', $value);
            $filtered = htmlentities($value, $this->getQuoteStyle(), $enc, $this->getDoubleQuote());

            if (!strlen($filtered)) {
                $ex = new \Exception('Encoding mismatch has resulted in htmlentities errors.');
                throw $ex;
            }
        }

        return $filtered;
    }
772221
private static function getOptions(array $values, array $selected, int $level = 0): array
    {
        $options = [];
        foreach ($values as $k => $v) {
            if (\strpos((string)$k, 'OPTGROUP') !== false) {
                $label = \str_replace(['&amp;nbsp;', '&amp;'], [Tags::NBSP, '&'], \htmlspecialchars((string)$v['name']));
                $optAttributes = ['label' => $label];
                if ($level > 0) {
                    $optAttributes['style'] = 'padding-left: '.(10 * $level).'px';
                }
                $options[] = Tags::optgroup(self::getOptions($v['options'], $selected, $level + 1), $optAttributes);
            } else {
                $optAttributes = [
                    'value' => $k,
                    'class' => 'opt-'.\str_replace('/', '', $k),
                ];
                if ($level > 0) {
                    $optAttributes['style'] = 'padding-left: '.(10 * $level).'px';
                }
                if (\in_array($k, $selected)) {
                    $optAttributes['selected'] = 'selected';
                }
                $options[] = Tags::option(
                    \str_replace(['&amp;nbsp;', '&amp;'], [Tags::NBSP, '&'], \htmlspecialchars((string)$v)),
                    $optAttributes
                );
            }
        }
        return $options;
    }
442372
public static function selectOptions($optionsArray, $selected = NULL) {
    $ret = array();
    foreach ($optionsArray as $value => $label) {
      if ($label instanceof HTMLTag) {
        $tag = $label;
        
        if ($tag->getAttribute('value') === $selected)
          $tag->setAttribute('selected','selected');

      } else {
        /* Interface Form Item */
        if($label instanceof \Psc\Form\Item) {
          $item = $label;
          $label = $item->getFormLabel();
          $value = $item->getFormValue();
        }
        
        $tag = static::tag('option',self::esc((string) $label),array('value'=>$value));
        if ($value === $selected)
          $tag->setAttribute('selected','selected');
      }
      
      $ret[] = $tag;
    }
    return $ret;
  }
755047
public function addOption($option, $value = null)
    {
        if (is_array($option)) {
            $this->options = $option + $this->options;
        } else {
            $this->options[$option] = $value;
        }
    }
506729
public static function getOptions($data, $key, $value) {
    $options = [];
    if (empty($data) && !is_array($data)) {
      return [];
    }

    foreach ($data as $item) {
      $options[$item->$key] = $item->$value;
    }

    return $options;
  }
103635
public static function enum($value, $options){

		$value = static::_nullValue($value);

		if(!in_array($value, $options)){

			return null;
		}

		return $value;
	}
297569
public function getArray(array $options = array()): array
    {
        $content = $this->getContent();

        if (is_null($content)) {
            return (array)$content;
        }

        return json_decode($this->content, true);
    }
617480
public static function extractResultErrorsInfo(array $result): array
    {
        assert(
            count($result) === 2 &&
            $result[static::REPLY_SUCCESS_VALUE] === null &&
            is_array($result[static::REPLY_ERRORS_INFO]) === true &&
            empty($result[static::REPLY_ERRORS_INFO]) === false
        );

        $value = $result[static::REPLY_ERRORS_INFO];

        return $value;
    }
961468
private function processField($value, array $option)
    {
        if($this->continue) {
            $cell = $this->unescapeEnclosure($value, $option['enclosure']);
            $this->joinCell($this->revert . $cell);
        } else {
            $cell = rtrim($value);
            $cell = $this->unescapeEnclosure($cell, $option['enclosure']);
            $this->setCell($cell);
            $this->col++;
        }
    }
312213
public static function email($name, $value = null, array $options = [])
    {
        self::exclure($options);

        return self::input('email', $name, $value, $options);
    }
730237
public function getOptionsByValue($value)
    {
        $options = array();

        foreach ($this->options as $option) {
            if ($option->value === $value) {
                $options[] = $option;
            }
        }

        return $options;
    }