src/Filter.php
public function groupBy($list, $property, $meta=null)
    {
        if (!$list) {
            return [];
        }
        if (!$meta) {
            if (!($first = current($list))) {
                throw new \UnexpectedValueException();
            }
            $meta = $this->mapper->getMeta(get_class($first));
        }

        $groups = [];

        $props = $meta->getProperties();
        foreach ($list as $object) {
            $propDef = !isset($props[$property]) ? null : $props[$property];
            $value = !$propDef || !isset($propDef['getter']) 
                ? $object->{$property} 
                : call_user_func(array($object, $propDef['getter']));

            $groups[$value][] = $object;
        }
        return $groups;
    }
public function groupBy($list, $property, $meta=null)
    {
        if (!$list) {
            return [];
        }
        if (!$meta) {
            if (!($first = current($list))) {
                throw new \UnexpectedValueException();
            }
            $meta = $this->mapper->getMeta(get_class($first));
        }

        $groups = [];

        $props = $meta->getProperties();
        foreach ($list as $object) {
            $propDef = !isset($props[$property]) ? null : $props[$property];
            $value = !$propDef || !isset($propDef['getter']) 
                ? $object->{$property} 
                : call_user_func(array($object, $propDef['getter']));

            $groups[$value][] = $object;
        }
        return $groups;
    }
public function groupBy ( $ list , $ property , $ meta = null ) { if ( ! $ list ) { return [ ] ; } if ( ! $ meta ) { if ( ! ( $ first = current ( $ list ) ) ) { throw new \ UnexpectedValueException ( ) ; } $ meta = $ this -> mapper -> getMeta ( get_class ( $ first ) ) ; } $ groups = [ ] ; $ props = $ meta -> getProperties ( ) ; foreach ( $ list as $ object ) { $ propDef = ! isset ( $ props [ $ property ] ) ? null : $ props [ $ property ] ; $ value = ! $ propDef || ! isset ( $ propDef [ 'getter' ] ) ? $ object -> { $ property } : call_user_func ( array ( $ object , $ propDef [ 'getter' ] ) ) ; $ groups [ $ value ] [ ] = $ object ; } return $ groups ; }
Iterate over an array of objects and group them by the value of a property

@return array[group] = class[]
Iterate over an array of objects and group them by the value of a property