Get the 'group by' key value.

@param Closure|string $group
@param string         $key
@param mixed          $value

@return string
969118
protected function getGroupByKey( $group, $key, $value )
    {
        if ( !is_string( $group ) && is_callable( $group ) )
        {
            return $group( $value, $key );
        }

        return Util::dataGet( $value, $group );
    }
445426
public function delete($key, $group = self::DEFAULT_GROUP) {
        if( isset($this->settings[$group][$key]) )
            unset($this->settings[$group][$key]);

        return $this;
    }
282816
public function getKey($value) {
		foreach ($this->collection as $k => $v) {
			if ($v === $value) {
				return $k;
			}
		}
		
		return null;
	}
1184358
public function getFieldByKey($key)
    {
        foreach ($this->groups as $group) {
            foreach ($group->getFields() as $field) {
                if ($field->getKey() == $key) {
                    return $field;
                }
            }
        }
    }
1162135
public function remove(string $group = "", string $key = ""): ArrayCache
    {
        $isGroupEmpty = ($group === "");
        $isKeyEmpty = ($key === "");

        if ($isGroupEmpty && !$isKeyEmpty) {
            throw new \LogicException(
                "removing a value by key is only possible when a group ".
                "is provided"
            );
        }

        if ($isKeyEmpty) {
            unset($this->values[$group]);
        } else {
            unset($this->values[$group][$key]);
        }

        return $this;
    }
523495
public function groupBy($groupBy, $preserveKeys = false)
    {
        if (is_array($groupBy)) {
            $nextGroups = $groupBy;

            $groupBy = array_shift($nextGroups);
        }

        $groupBy = $this->valueRetriever($groupBy);

        $results = [];

        foreach ($this->items as $key => $value) {
            $groupKeys = $groupBy($value, $key);

            if (! is_array($groupKeys)) {
                $groupKeys = [$groupKeys];
            }

            foreach ($groupKeys as $groupKey) {
                $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;

                if (! array_key_exists($groupKey, $results)) {
                    $results[$groupKey] = new static;
                }

                $results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value);
            }
        }

        $result = new static($results);

        if (! empty($nextGroups)) {
            return $result->map->groupBy($nextGroups, $preserveKeys);
        }

        return $result;
    }
170364
public static function group($group, \Closure $closure)
    {
        self::$group = $group;
        call_user_func($closure, self::getInstance());
        self::$group = null;
    }
34040
public function where($key, $value)
    {
        return collect($this->all()->where($key, $value)->first());
    }
662100
public function get($value, $pattern, $group = 0)
    {
        if (!isset($value)) {
            return null;
        }
        
        return preg_match($pattern, $value, $matches) && isset($matches[$group]) ? $matches[$group] : null;
    }
689061
public function getByGroupId($value, $limit = 1000, $useConnection = 'read')
    {
        if (is_null($value)) {
            throw new \Exception('Value passed to ' . __FUNCTION__ . ' cannot be null.');
        }

        $query = 'SELECT * FROM `project` WHERE `group_id` = :group_id ORDER BY title LIMIT :limit';
        $stmt = Database::getConnection($useConnection)->prepare($query);
        $stmt->bindValue(':group_id', $value);
        $stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT);

        if ($stmt->execute()) {
            $res = $stmt->fetchAll(\PDO::FETCH_ASSOC);

            $map = function ($item) {
                return new Project($item);
            };
            $rtn = array_map($map, $res);

            $count = count($rtn);

            return array('items' => $rtn, 'count' => $count);
        } else {
            return array('items' => array(), 'count' => 0);
        }
    }
223968
public function getByKey($key, $group = null) {
        $query =  $this->model
            ->where('key', $key);

        if(! is_null($group))
            $query->where('group', $group);

        return $query->get();
    }
1294948
public function group($grouper, bool $saveKeys = false): self
    {
        // init
        $result = [];

        // Iterate over values, group by property/results from closure.
        foreach ($this->getGenerator() as $key => $value) {
            if (\is_callable($grouper)) {
                $groupKey = $grouper($value, $key);
            } else {
                $groupKey = $this->get($grouper, null, $this->getArray());
            }

            $newValue = $this->get($groupKey, null, $result);

            if ($groupKey instanceof self) {
                $groupKey = $groupKey->getArray();
            }

            if ($newValue instanceof self) {
                $newValue = $newValue->getArray();
            }

            // Add to results.
            if ($groupKey !== null) {
                if ($saveKeys) {
                    $result[$groupKey] = $newValue;
                    $result[$groupKey][$key] = $value;
                } else {
                    $result[$groupKey] = $newValue;
                    $result[$groupKey][] = $value;
                }
            }
        }

        return static::create(
            $result,
            $this->iteratorClass,
            false
        );
    }
1240837
static function groups($key = null)
    {
        if (!isset(self::$trace)) self::$trace = new Trace('TRACE');
        if (isset($key)){
            return self::$trace->__get($key);
        }else{
            return self::$trace;
        }
    }
867253
private static function flattenArgument (&$value, $key) {
        if ($value instanceof Closure) {
            $closureReflection = new ReflectionFunction($value);
            $value = sprintf('(Closure at %s:%s)', $closureReflection->getFileName(), $closureReflection->getStartLine());
        } elseif (is_object($value)) {
            $value = sprintf('object(%s)', get_class($value));
        } elseif (is_resource($value)) {
            $value = sprintf('resource(%s)', get_resource_type($value));
        }
    }
1219778
public function with($key, $value = null)
    {
        $values = (is_array($key) || $key instanceof Traversable) ? $key : [$key => $value];

        return $this->copy()->update($values);
    }
862242
public String put(String group, String key, String value) {
		return this.groupedMap.put(group, key, value);
	}
216085
function group($key = null)
    {
        if (empty($key)) $key = sizeof($this->children);
        if (!isset($this->children[$key])){
            $this->children[$key] = new Trace($key, null);
        }
        return $this->children[$key];
    }