Return the option which has the given value.
If there are multiple options with the same value, the first will be returned.

@param $value
@return Option
771525
public function getOptionByValue($value)
    {
        // walk all options
        foreach ($this->options as $option) {
            if ($option instanceof Option) {
                if ($option->getValue() == $value) {
                    return $option;
                }
            } else {
                if ($option instanceof Optgroup) {
                    $options = $option->getOptions();
                    foreach ($options as $option2) {
                        if ($option2->getValue() == $value) {
                            return $option2;
                        }
                    }
                }
            }
        }

        return null;
    }
911565
public function search( $value )
	{
		if( $value == $this->value )
			return $this;
		else if( $value < $this->value )
		{
			if( $this->left )
				return $this->left->search( $value );
		}
		else if( $value > $this->value )
		{
			if( $this->right )
				return $this->right->search( $value );
		}
		return NULL;
	}
950538
public function value($value)
    {
        if (is_null($value)) $value = '';
        $this->value = (string)$value;
        return $this;
    }
16059
public function Options($Key, $Value = NULL) {
      if ($Value !== NULL) {
         $this->_Options[$Key] = $Value;
         return $this;
      } elseif (isset($this->_Options[$Key]))
         return $this->_Options[$Key];
      else
         return NULL;
   }
45186
public function setOption(string $option, $value) : object
    {
        $this->options[$option] = $value;
        return $this;
    }
942828
private function getValue($value)
    {
        if (!is_string($value)) {
            return $value;
        }

        if ($value[0] != '%' || $value[strlen($value) - 1] != '%')  {
            return $value;
        }

        $parameter = trim($value, '%');
        if ($this->container->hasParameter($parameter)) {
            return $this->container->getParameter($parameter);
        }

        return $value;
    }
930575
public static function getTypeFromValue($value)
    {
        switch (gettype($value)) {
            case 'boolean':
                if ($value) {
                    return Type::getTrue();
                }

                return Type::getFalse();

            case 'integer':
                return Type::getInt(false, $value);

            case 'double':
                return Type::getFloat($value);

            case 'string':
                return Type::getString($value);

            case 'array':
                return Type::getArray();

            case 'NULL':
                return Type::getNull();

            default:
                return Type::getMixed();
        }
    }
974526
public function get(string $key, $value = null)
    {
        if ($this->__isset($key)) {
            $value = $this->options[$key];
        }

        return $value;
    }
974224
public static function setOption($option, $value)
    {
        $that = self::getInstance();

        if (! is_array($value)) {
            return $that->settings[$option] = $value;
        }

        if (array_key_exists($option, $that->settings)) {
            $that->settings[$option] = array_merge_recursive(
                is_array($that->settings[$option]) ? $that->settings[$option] : [],
                $value
            );
        } else {
            foreach ($value as $key => $value) {
                $that->settings[$option][$key] = $value;
            }
        }

        return $that->settings[$option];
    }
485267
public static function getByValue($value)
    {
        $class = get_called_class();
        $constants = array_flip(static::getConstants());
        if (isset($constants[$value])) {
            return self::$instances[$class][$constants[$value]] = new $class($value);
        } else {
            throw new \InvalidArgumentException('"' . $value . '" not defined');
        }
    }
1048849
public function resolve($value)
    {
        try {
            foreach ($this->thenCallables as $then) {
                $value = $then($value);
            }
        } catch (\Exception $e) {
            foreach ($this->rejectCallables as $reject) {
                $e = $reject($e);
            }
        }

        return $value;
    }
1188099
public static function string($value)
    {
        if (static::stringable($value)) {
            $value = (string) $value;
        } else {
            $value = null;
        }

        return $value;
    }
1358663
public function set($option, $value)
    {
        if (method_exists($this, $option)) {
            return $this->{$option}($value);
        }
        $this->_options[$option] = $value;

        return $this;
    }
1137091
public function deselectByValue($value)
	{
		foreach ( $this->getOptionsByValue($value) as $option ) {
			$option->deselect();
		}

		return $this;
	}
1041174
public function value($value = null)
    {
        if (func_num_args() === 0) {
            return $this->_data['value'];
        }
        $value = (string) $value;
        return $this->_data['value'] = $value;
    }
1370059
public function setValue($value = null) {

		if(isset($value)) {
			parent::setValue($value);
		}

		if(isset($this->selectedOption) && $this->selectedOption->getValue() != $this->getValue()) {
			$this->selectedOption->unselect();
			$this->selectedOption = null;
		}

		if(!isset($this->selectedOption)) {
			foreach($this->options as $o) {
				if($o->getValue() == $this->getValue()) {
					$o->select();
					$this->selectedOption = $o;
					break;
				}
			}
		}

		return $this;

	}
780035
public function getKey($value): Option
	{
		if ($this->containsValue($value))
		{
			return new Option(array_search($value, $this->data, true), true);
		}
		else
		{
			return new Option(null, false);
		}
	}