Set array[$key] to $value if $var is not empty

$value = $var if $value is not set

@param      $array
@param      $key
@param      $var
@param null $value
@return mixed
434089
protected function setOption(&$array, $key, $var, $value = null)
    {
        $value = ($value === null) ? $var : $value;

        if (!empty($var)) {
            $array[$key] = $value;
        }

        return $array;
    }
792028
public function setPost($key, $value = null) {
        if (is_array($key)) {
            $this->POST = $key;
        } else {
            $this->POST[$key] = $value;
        }
        return $this;
    }
460575
public function array_combine( array $array, $key, $value = null ) {
		$keys   = $this->array_pluck( $array, $key );
		$values = empty( $value ) ? $array : $this->array_pluck( $array, $value );

		return array_combine( $keys, $values );
	}
345569
public function getKey(array $array, string $value, $defaultValue = null)
    {
        foreach ($array as $key => $nextValue) {
            if (strcasecmp($nextValue, $value) == 0) {
                return $key;
            }
        }

        return $defaultValue;
    }
915423
public static function tryGetKeysChainValue($array)
    {
        $arguments = func_get_args();
        $numArguments = func_num_args();

        $currentArray = $array;
        for ($i = 1; $i < $numArguments; ++$i) {
            if (is_array($currentArray)) {
                if (array_key_exists($arguments[$i], $currentArray)) {
                    $currentArray = $currentArray[$arguments[$i]];
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }

        return $currentArray;
    }
1078606
public static function prepend($array, $value, $key = null)
    {
        if (is_null($key)) {
            array_unshift($array, $value);
        } else {
            $array = [$key => $value] + $array;
        }

        return $array;
    }
143892
public function add($key, $value = null)
    {
        if (is_array($key)) {
            foreach ($key as $innerKey => $innerValue) {
                Arr::set($this->variables, $innerKey, $innerValue);
            }
        } elseif ($key instanceof Closure) {
            $this->variables[] = $key;
        } else {
            Arr::set($this->variables, $key, $value);
        }

        return $this;
    }
632177
public static function get( $array, $key, $default = NULL )
    {
        if ( is_null( $key ) ) return $array;

        if ( isset( $array[ $key ] ) ) return $array[ $key ];

        foreach ( explode( '.', $key ) as $segment )
        {
            if ( !is_array( $array ) || !array_key_exists( $segment, $array ) )
            {
                return Util::value( $default );
            }

            $array = $array[ $segment ];
        }

        return $array;
    }
1146043
public static function ensure_key_present($key, $array)
	{
		// ensure that the array we are checking is an array
		if (! is_array($array))
		{
			throw new ArraysException('Value of $array is not an array');
		}

		// if we are not checking an array of keys,
		// then just return array_key_exists check
		if (! is_array($key))
		{
			return array_key_exists($key, $array);
		}

		// gather the keys of the array
		$array_keys = array_keys($array);

		// itterate over the keys to check
		foreach ($key as $check_key)
		{
			// if the key does not exists
			if (! in_array($check_key, $array_keys))
			{
				// return false
				return false;
			}
		}

		// all keys exist
		return true;
	}
953053
public static function get($array, $key, $default = null)
	{
		if (!static::accessible($array))
			return value($default);

		if (is_null($key))
			return $array;

		if (static::exists($array, $key))
			return $array[(string) $key];


		foreach (static::toKey($key) as $segment) {
			if (static::accessible($array) && static::exists($array, $segment)) {
				$array = $array[$segment];
			} else {
				return value($default);
			}
		}

		return $array;
	}
741958
public static function get($array, $key, $default = null)
    {
        return is_array($key)
            ? static::getArray($array, $key, $default)
            : parent::get($array, $key, $default);
    }
1214586
public static function getValue($array, $key, $default = null)
    {
        if (is_string($key)) {
            // Iterate path
            $keys = explode('.', $key);
            foreach ($keys as $key) {
                if (!isset($array[$key])) {
                    return $default;
                }
                $array = &$array[$key];
            }
            // Get value
            return $array;
        } elseif (is_null($key)) {
            // Get all data
            return $array;
        }
        return null;
    }
1139651
public static function set(&$array, $key = null, $value = null, $opr = null)
    {
        if (null === $value) {
            return $array;
        }
        if (null === $key) {
            return $array = $value;
        }
        if (null === $opr) {
            return $array[$key] = $value;
        }

        $keys = explode($opr, $key);
        foreach ($keys as $key) {
            if (!isset($array[$key]) || !is_array($array[$key])) {
                $array[$key] = [];
            }

            $array = &$array[$key];
        }

        $array = $value;

        return $array;
    }
1178492
public static function dotSet(array $array, $key, $value)
    {
        $path = explode('.', $key);
        $total = count($path);

        $current = &$array;

        for ($ii = 0; $ii < $total; $ii++) {
            if ($ii === $total - 1) {
                $current[$path[$ii]] = $value;
            } else {
                if (!is_array($current)) {
                    throw new LackOfCoffeeException(
                        'Part of the path is not an array.'
                    );
                }

                if (!array_key_exists($path[$ii], $current)) {
                    $current[$path[$ii]] = [];
                }

                $current = &$current[$path[$ii]];
            }
        }
    }
11836
public static function pluck( $array, $value, $key = NULL )
    {
        $result = [ ];

        foreach ( $array as $item )
        {
            $itemValue = is_object( $item ) ? $item->{$value} : $item[ $value ];

            if ( is_null( $key ) )
            {
                $result[ ] = $itemValue;
            }
            else
            {
                $itemKey = is_object( $item ) ? $item->{$key} : $item[ $key ];

                $result[ $itemKey ] = $itemValue;
            }
        }

        return $result;
    }
751355
public static function set(array &$array, $keyPath, $value)
    {
        self::checkKeyPathIsValidAndNonEmpty($keyPath);
        $keys = self::explodeKeys(strval($keyPath));
        $result = $array;
        $ptr = &$result;

        $parentKeys = array();
        while ($keys !== array()) {
            $key = array_shift($keys);
            $parentKeys[] = $key;

            if (!array_key_exists($key, $ptr)) {
                $ptr[$key] = $keys === array() ? $value : array();
                $ptr = &$ptr[$key];
                continue;
            }
            $ptr = &$ptr[$key];
            if ($keys === array()) {
                $ptr = $value;
                break;
            }
            elseif (!is_array($ptr)) {
                throw new InconsistentKeyTypes($ptr, array(), implode('.', $parentKeys));
            }
        }

        $array = $result;
    }
1365503
public function set($key, $value = null)
    {
        if (is_array($key))
        {
            foreach ($key as $name => $value)
            {
                $this->_data[$name] = $value;
            }
        }
        else
        {
            $this->_data[$key] = $value;
        }

        return $this;
    }