Exchanges all keys with their associated values in the array.
Note: This function can only flip STRING and INTEGER values. Other types will throw a E_WARNING
(no exceptions, sorry :( )

@throws ArrayObjectException
@return $this
498189
public function flip()
    {
        try {
            $this->val(array_flip($this->val()));
        } catch (\ErrorException $e) {
            throw new ArrayObjectException($e->getMessage());
        }

        return $this;
    }
717567
protected function convertValue()
    {
        $values = $this->getValue();
        $convertedValues = array();

        if (($values instanceof Collection) || is_array($values)) {
            foreach ($values as $value) {
                if (!is_object($value) || !method_exists($value, 'getId')) {
                    continue;
                }

                $convertedValues[] = $value->getId();
            }
        } elseif (is_object($values) && method_exists($values, 'getId')) {
            $convertedValues[] = $values->getId();
        }

        return $convertedValues;
    }
915171
public function values($values)
    {
        if(!$values instanceof KDatabaseQuerySelect)
        {
            if (!$this->columns && !is_numeric(key($values))) {
                $this->columns(array_keys($values));
            }

            $this->values[] = array_values($values);
        }
        else $this->values = $values;

        return $this;
    }
1144224
public function values()
    {
        $count       = $this->count()->toNative();
        $valuesArray = new \SplFixedArray($count);

        foreach ($this->items as $key => $item) {
            $valuesArray->offsetSet($key, $item->getValue());
        }

        return new Collection($valuesArray);
    }
96095
protected function transfer()
    {
        $names = array_column($this->rawFields, 'name');
        if (array_unique($names) !== $names) {
            throw new Exception('Each field name must be unique. Please check the profided field names');
        }

        $mappers = [];
        foreach ($this->rawFields as $rawField) {
            $properties = (array) $rawField;

            if (!$this->isReadOnly) {
                //This make sure the field name is updated
                $properties['name'] = Field::getNameFromArray($properties);

                $this->presetProperties($properties)
                    ->setLabels($properties)
                    ->setPlaceholder($properties)
                    ->setOptions($properties);
            }

            $field = Field::fromArray($properties, $this->localeGroup, $this->languages);
			
            $mappers[] = new FieldMapper($field, (array) $rawField);
        }
		
        $optimizer = new FieldsOptimizer($mappers);
        $this->fields = $optimizer->optimize()->getFields();

        return $this;
    }
976797
public function flip(): self
    {
        $collection = Factory::create();
        foreach ($this->items as $key => $value) {
            $collection->set($value, $key);
        }

        return $collection;
    }
1149167
public function flipBoolValue($field): self
    {
        if (!$this->getCollectedObjects()) {
            $this->collectObjects(false, true);
        }

        foreach ($this->getCollectedObjects() as $object) {
            /** @var Entity $object */
            $object->flipBoolValue($field);
        }

        return $this;
    }
578271
public function to($values): self
    {
        $values = is_string($values) || is_integer($values) ? func_get_args() : $values;

        foreach ($values as $value) {
            if (! in_array($value, $this->to)) {
                $this->to[] = $value;
            }
        }

        return $this;
    }
1214913
final public function getPrimaryKeyValues() : array
    {
        $keys = static::getPrimaryKeys();
        $values = array_intersect_key($this->data, array_flip($keys));

        return $values;
    }
51136
public function values( array $values )
	{
		// do nothing if we get nothing
		if ( empty( $values ) )
		{
			return $this;
		}
		
		// check if the the passed array is a collection.
		// because we want to be able to insert bulk values.
		if ( !\CCArr::is_collection( $values ) )
		{
			$values = array( $values );
		}
		
		// because we could recive the arrays in diffrent order 
		// we have to sort them by their key.
		foreach( $values as $key => $value )
		{
			ksort( $value ); $values[$key] = $value;
		}
		
		// merge the new values with the existing ones.
		$this->values = array_merge( $this->values, $values ); 
		
		// return self so we can continue running the next function
		return $this;
	}
1085203
public function setValues(array $values = array())
    {
        foreach ($values as $k => $v) {
            $this->set($k, $v);
        }

        return $this;
    }
399501
public function bind($values)
    {
        if ( ! is_array($values) ) {
            throw new InvalidException('Values assigned to a block must be an array');
        }

        // only one value
        if ( ! $this->isArrayMulti($values) ) {
            $this->bindings[] = $values;
            return $this;
        }

        // multiple values
        foreach ( $values as $line ) {
            $this->bind($line);
        }

        return $this;
    }
849908
protected function _toArrayWithoutPrimaryKeys()
    {
        $ret = $this->toArray();
        unset($ret[$this->getModel()->getPrimaryKey()]);
        foreach ($this->_getSiblingRows() as $r) {
            $primaryKey = $r->getModel()->getPrimaryKey();
            if ($primaryKey) {
                unset($ret[$primaryKey]);
            }
        }
        return $ret;
    }
194373
public function toObjectArray()
  {
    $array = (func_num_args() > 1) ? $this->toArray(1) : $this->toArray();

    for($i = 0; $i < count($array); $i++)
    {
      $array[$i] = (object) $array[$i];
    }

    return $array;
  }
180132
public function setValue($value) {
		if ($value instanceof \ArrayObject)
			$this->value = $value->getArrayCopy();
		elseif (is_object($value))
			$this->value = get_object_vars($value);
		elseif (is_array($value))
			$this->value = $value;
		else
			throw new \InvalidArgumentException("Method 'setValue' expected an object or array value");
		
		return $this;
	}
554112
public function sortKeys()
    {
        if ($this->isNotEmpty()) {
            foreach ($this->rows as &$row) {
                ksort($row);
            }
        }
        return $this;
    }
121025
public function mergeF ()
	{
		$args = func_get_args();

		foreach ($args as $arg) {
			if (is_an_array($arg)) {
				if ($arg instanceof self) {
					$arg = $arg->to_array();
				}

				foreach ($arg as $key => $value) {
					$this->offsetSet(strtolower($key), $value);
				}
			} else {
				/* XXX: Do we really support this? Object instances are
				 *      supposed to be hashes, Vector instances can be appended
				 *      to. */
				$this->storage []= $arg;
			}
		}

		return $this;
	}