public static function countBy($list, $iterator, $context = null)
    {
        return static::map(static::groupBy($list, $iterator, $context), function ($item) {
            return static::size($item);
        });
    }
public static function countBy($list, $iterator, $context = null)
    {
        return static::map(static::groupBy($list, $iterator, $context), function ($item) {
            return static::size($item);
        });
    }
public static function countBy ( $ list , $ iterator , $ context = null ) { return static :: map ( static :: groupBy ( $ list , $ iterator , $ context ) , function ( $ item ) { return static :: size ( $ item ) ; } ) ; }
Sorts a list into groups and returns a count for the number of objects in each group. Similar to groupBy, but
instead of returning a list of values, returns a count for the number of values in that group.

@category Collection Functions

@param traversable $list the list of items to group and count
@param callable,scalar $iterator the function to generate the key or a property name
@param object $context optional, if provided will become the context of $iterator

@return array
Sorts a list into groups and returns a count for the number of objects in each group . Similar to groupBy but instead of returning a list of values returns a count for the number of values in that group .