@param array $values
@param array $old

@return array
488553
public function getValues(array $values, array $old = []): array
    {
        $result = $old;

        foreach ($this->controls as $control) {
            $name = $control->getName();
            if (array_key_exists($name, $values)) {
                $result[$name] = $control->getValue($values[$name], $old[$name] ?? '');
            }
        }

        return $result;
    }
186213
public function toKeyValue(array $values)
    {
        $result = [];

        foreach ($values as $key => $value) {
            if (is_array($value)) {
                $result[$key] = $this->toKeyValue($value);
            } elseif (is_object($value)) {
                $result[$key] = $this->toKeyValue((array) $value);
            } else {
                $result[$key] = $value;
            }
        }

        return $result;
    }
1302122
public function insert(array $values)
    {
        $n_inserted = 0;

        $resets = [];

        foreach ($values as $key => $value) {
            if (is_array($value)) {
                $n_inserted += $this->insertOne($value);
            } else {
                $resets[$key] = $value;
            }

            unset($values[$key]);
        }

        if (!empty($resets)) {
            $n_inserted += $this->insertOne($resets);
        }

        return $n_inserted;
    }
429510
public function update(array $values)
    {
        $result = parent::update($values);

        $this->handler->setBuilder($this)
            ->invalidateQuery(Reflector::QUERY_TYPE_UPDATE, $values);

        return $result;
    }
1144484
public function diff(array $oldData, array $newData)
    {
        $diff = [];
        $keys = array_keys($oldData + $newData);
        
        foreach ($keys as $field) {
            $old = array_key_exists($field, $oldData) ? $oldData[$field] : null;
            $new = array_key_exists($field, $newData) ? $newData[$field] : null;

            if ($old == $new) {
                $row = ['old' => '', 'new' => '', 'same' => $old];
            } else {
                $row = ['old' => $old, 'new' => $new, 'same' => ''];
            }

            $diff[$field] = $row;
        }

        return $diff;
    }
607635
public function withValues(array $values) : self
    {
        $new = clone $this;
        foreach ($values as $property => $value) {
            $new->data[$property] = $value;
        }

        return $new;
    }
1305496
protected function updateEnabled( $new, $old )
    {
        $result     = array();
        $service    = $this->getServiceLocator()
                           ->get( 'Locale' );

        foreach ( $service->getAvailableFlags() as $locale => $enabled )
        {
            $result[$locale] = (string) (
                ! empty( $new[$locale] ) ||
                in_array( $locale, $new )
            );
        }

        return $result;
    }
1202117
private function array_filter_walker( $values = array() ) {

		$values = (array) $values;

		foreach ( $values as $k => $v ) {
			if ( is_object( $v ) ) {
				// Skip objects
				continue;
			} elseif ( is_array( $v ) ) {
				if ( empty( $v ) ) {
					// Filter values with empty arrays
					unset( $values[ $k ] );
				}
			} else {
				if ( ! $v ) {
					// Filter empty values
					unset( $values[ $k ] );
				}
			}
		}

		return $values;

	}
686537
protected function flattenArray(array $values, $previous = '')
    {
        $result = array();
        foreach ($values as $key => $value) {
            if ($previous) {
                $key = $previous.'['.$key.']';
            }
            if (is_array($value)) {
                $result = $result + $this->flattenArray($value, $key);
            } else {
                $result[$key] = $value;
            }
        }

        return $result;
    }
122885
protected static function checkUpdate(array $values)
    {
        $errors = [];
        foreach ($values as $key => $value) {
            $errors += static::checkProperty($key, $value);
        }
        return $errors;
    }
1018881
public function process(array $values)
    {
        $results = [];

        foreach ($values as $value) {
            $results = array_merge($results,
                $this->getSolrRootlineForCategoryId($value));
        }

        return $results;
    }
904968
protected function addUpdatedAtColumn(array $values)
    {
        if (! $this->model->usesTimestamps()) return $values;

        $column = $this->model->getUpdatedAtColumn();

        return array_add($values, $column, $this->model->freshTimestampString());
    }
1134972
public function arrayToMultiselect(array $values)
    {
        // First clean the array
        foreach ($values as $k => $v) {
            if (empty($v)) {
                unset($values[$k]);
            }
        }

        // Encode
        $values = (empty($values) ? '^^' : encodeMultienumValue($values));

        // Then return the array
        return $values;
    }
1056501
private function normalizeBetweenValues(array $values): ?array
    {
        if (2 !== \count($values)) {
            $this->getLogger()->notice('Invalid filter ignored', [
                'exception' => new InvalidArgumentException(sprintf('Invalid format for "[%s]", expected "<min>..<max>"', self::PARAMETER_BETWEEN)),
            ]);

            return null;
        }

        if (!is_numeric($values[0]) || !is_numeric($values[1])) {
            $this->getLogger()->notice('Invalid filter ignored', [
                'exception' => new InvalidArgumentException(sprintf('Invalid values for "[%s]" range, expected numbers', self::PARAMETER_BETWEEN)),
            ]);

            return null;
        }

        return [$values[0] + 0, $values[1] + 0]; // coerce to the right types.
    }
1067242
private static function getValues(array $values)
    {
        $bag = MutableBag::from($values);
        foreach ($bag as $k => $v) {
            /** @var Bag $v */
            if (is_array($v) && !is_callable($v)) {
                $bag[$k] = Bag::from($v)
                    ->call(function (array $a) {
                        return [Json::dump($a)];
                    })
                    ->join(' ')
                ;
            } elseif (is_string($v) || (is_object($v) && method_exists($v, '__toString'))) {
                $bag[$k] = (string) $v;
            } else {
                $bag->remove($k);
            }
        }

        return $bag->immutable();
    }
1214381
protected function getValues(array $values)
    {
        $array = [];

        $versionedKeys = array_merge(
            $this->model->getVersionedAttributeNames(),
            [$this->model->getLatestVersionColumn(), $this->model->getVersionColumn(), $this->model->getVersionKeyName()]
        );

        foreach ($values as $key => $value) {
            if (! $this->isVersionedKey($key, $versionedKeys)) {
                $array[$key] = $value;
            }
        }

        return $array;
    }
1126749
protected function getBindingsMergedWithValues(array $values)
    {
        $bindings = [];

        foreach ($values as $key => $value)
        {
            $bindings[$key .'_update'] = $value;
        }

        return array_merge($this->getBindings(), $bindings);
    }