public function countBy($callback = null)
    {
        if (is_null($callback)) {
            $callback = function ($value) {
                return $value;
            };
        }

        return new static($this->groupBy($callback)->map(function ($value) {
            return $value->count();
        }));
    }
public function countBy($callback = null)
    {
        if (is_null($callback)) {
            $callback = function ($value) {
                return $value;
            };
        }

        return new static($this->groupBy($callback)->map(function ($value) {
            return $value->count();
        }));
    }
public function countBy ( $ callback = null ) { if ( is_null ( $ callback ) ) { $ callback = function ( $ value ) { return $ value ; } ; } return new static ( $ this -> groupBy ( $ callback ) -> map ( function ( $ value ) { return $ value -> count ( ) ; } ) ) ; }
Count the number of items in the collection using a given truth test.

@param  callable|null  $callback
@return static
Count the number of items in the collection using a given truth test .