Return the array in a key-value form, based on the
given parameters for key and value.

@param array|object[] $collection
@param string         $key
@param string         $value
@param bool           $useDotSyntax

@return array
496033
public static function toKeyValue($collection, $key, $value, $useDotSyntax = false)
    {
        $keyValueArray = [];
        foreach ($collection as $item) {
            $itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
            $keyValue = self::get($itemArray, $key, null, $useDotSyntax);
            $keyValueArray[$keyValue] = $itemArray[$value];
        }

        return $keyValueArray;
    }
645229
public function getAll($key, $value = null)
    {
        $collection = new self();

        foreach ($this->items as $item) {
            if ($item->{$key} == $value) {
                $collection->push($item);
            }
        }

        return $collection;
    }
736608
public static function set($array, $key, $value = null, $useDotSyntax = false)
    {
        // Normalize array
        $array = $array ?: [];

        // Check if key is empty
        if (StringHelper::emptyString($key, true)) {
            throw new InvalidArgumentException(__METHOD__ . ': Key cannot be empty');
        }

        /**
         * Split name using dots.
         *
         * Just checking whether the key doesn't have any dots
         * but $useDotSyntax is true by default.
         */
        $keyParts = explode('.', $key);
        $useDotSyntax = $useDotSyntax && count($keyParts) > 1;

        // Set simple value, without dot syntax
        if (!$useDotSyntax) {
            if (is_null($value) && isset($array[$key])) {
                unset($array[$key]);
            } elseif (!is_null($value)) {
                $array[$key] = $value;
            }
        } else {
            // Recursive call
            $base = $keyParts[0];
            unset($keyParts[0]);

            // Check if the base array exists
            if (!isset($array[$base])) {
                $array[$base] = [];
            }

            // Get key, base array and continue
            $key = implode('.', $keyParts);
            $innerArray = $array[$base];

            $array[$base] = static::set($innerArray, $key, $value, $useDotSyntax);
        }

        return $array;
    }
311149
public function set($key, $value): ArrayCollection
    {
        if ($key === null) {
            $this->items[] = $value;
        } else {
            $this->items[$key] = $value;
        }

        return $this;
    }
1133092
protected function collection_to_array($collection)
    {
        if ($collection instanceof self) {
            return $collection->toArray();

        } else if ($collection instanceof \Traversable) {
            return iterator_to_array($collection);

        } else if ($collection instanceof Arrayable) {
            return $collection->toArray();

        } else if ($collection instanceof Jsonable) {
            return json_decode($collection->toJson(), true);

        } else if (is_object($collection) || is_array($collection)) {
            return (array)$collection;

        } else {
            throw new \InvalidArgumentException(sprintf(
                '$collection has type %s, which is not collection-like',
                gettype($collection)
            ));
        }
    }
463657
def get_collection(self, key, using_name=True):
        
        object_ = self.application.get_object(key, using_name=using_name)
        collection = Collection.from_dict(object_.__dict__)
        for http_cmd in ["get", "post", "put", "delete"]:
            collection.__setattr__(http_cmd, self.auth.__getattribute__(http_cmd))
        return collection
168173
public function load($str, Collection $collection)
	{
		$this->str = $str;
		$this->collection = $collection;

		return $this;
	}
1150370
public function pluckCallback(Collection $collection, $key, array $matches)
    {
        $indexes = explode(',', $key);
        $result = array();
        foreach ($indexes as $idx) {
            $idx = trim($idx);
            if ($idx != '') {
                if (array_key_exists($idx, $this->contents)) {
                    $result[$idx] = $this->contents[$idx];
                }
            }
        }
        return $result;
    }
330028
protected function serializeEloquentCollection(Collection $value)
    {
        $items = [];
        foreach ($value as $v) {
            $items[] = $this->serializeObject($v);
        }

        return [self::MAP_TYPE => 'array', self::SCALAR_VALUE => $items];
    }
925473
public function add(string $key, string $value): HeaderCollection
    {
        return $this->addMultiple([$key => $value]);
    }
1324244
public function get($collection = "")
		{

			$documents = $this->getCursor($collection);

			$returns = array();

			if ($documents && !empty($documents)) {
				foreach ($documents as $doc) {
					$returns[] = $doc;
				}
			}

			return $returns;
		}
207792
public function pluck($collection=null, $key=null) {
    list($collection, $key) = self::_wrapArgs(func_get_args(), 2);
    
    $collection = (array) self::_collection($collection);
        
    $return = array();
    foreach($collection as $item) {
      foreach($item as $k=>$v) {
        if($k === $key) $return[] = $v;
      }
    }
    return self::_wrap($return);
  }
1191853
public function get($key, $default = null)
    {
        return ArrayHelper::get($this->getItems(), $key, $default, $useDotSyntax = true);
    }
915072
public function hincrby($collection, $key, $field, $by = 1) {

        $current = $this->hget($collection, $key, $field, 0);
        $newone  = $current+$by;

        $this->hset($collection, $key, $field, $newone);

        return $newone;
    }
427115
protected function copyCollectionWith(Collection $collection, array $values)
    {
        $collection = clone $collection;

        $collection->exchangeArray($values);

        return $collection;
    }
1077713
public function set($collection, $value = null)
    {
        if (func_num_args() === 1) {
            return parent::merge($collection, true);
        }
        $this->_data[$collection] = $value;
        return $this;
    }
62273
public function each($collection=null, $iterator=null) {
    list($collection, $iterator) = self::_wrapArgs(func_get_args(), 2);
    
    if(is_null($collection)) return self::_wrap(null);
    
    $collection = (array) self::_collection($collection);
    if(count($collection) === 0) return self::_wrap(null);
    
    foreach($collection as $k=>$v) {
      call_user_func($iterator, $v, $k, $collection);
    }
    return self::_wrap(null);
  }