original_string: public function groupBy($criteria)
      {
          $criteria = $this->factoryCallableCriteria($criteria);
          $groups   = $this->create();
  
          $this->each(function ($element, $key) use ($groups, $criteria) {
              $groupName  = $criteria($element, $key);
              $elements   = $groups->offsetGet($groupName, array());
              $elements[] = $element;
              $groups[$groupName] = $elements;
          });
  
          return $groups;
      }
code: public function groupBy($criteria)
      {
          $criteria = $this->factoryCallableCriteria($criteria);
          $groups   = $this->create();
  
          $this->each(function ($element, $key) use ($groups, $criteria) {
              $groupName  = $criteria($element, $key);
              $elements   = $groups->offsetGet($groupName, array());
              $elements[] = $element;
              $groups[$groupName] = $elements;
          });
  
          return $groups;
      }
code_tokens: public function groupBy ( $ criteria ) { $ criteria = $ this -> factoryCallableCriteria ( $ criteria ) ; $ groups = $ this -> create ( ) ; $ this -> each ( function ( $ element , $ key ) use ( $ groups , $ criteria ) { $ groupName = $ criteria ( $ element , $ key ) ; $ elements = $ groups -> offsetGet ( $ groupName , array ( ) ) ; $ elements [ ] = $ element ; $ groups [ $ groupName ] = $ elements ; } ) ; return $ groups ; }
docstring: Group elements by the given criteria
  
  @param mixed $criteria it can be either a callable function or a string,
  representing a key of an element
  
  @return Hash
docstring_tokens: Group elements by the given criteria