@@ -91,7 +91,7 @@ function paginate(array $items, int $page, int $per_page, bool $preserve_keys =
9191 return array_slice ($ items , $ offset , $ per_page , $ preserve_keys );
9292}
9393
94- function sum_values (iterable $ items , callable $ callback , int $ mode = 0 )
94+ function sum (iterable $ items , callable $ callback , int $ mode = 0 )
9595{
9696 $ sum = 0 ;
9797 foreach ($ items as $ key => $ value ) {
@@ -100,63 +100,3 @@ function sum_values(iterable $items, callable $callback, int $mode = 0)
100100
101101 return $ sum ;
102102}
103-
104- function count_values (iterable $ items , callable $ callback , int $ mode = CALLBACK_USE_VALUE ): int
105- {
106- $ count = 0 ;
107- foreach ($ items as $ key => $ value ) {
108- if (true === call_user_func_array ($ callback , __args ($ mode , $ key , $ value ))) {
109- $ count ++;
110- }
111- }
112-
113- return $ count ;
114- }
115-
116- function max_value (iterable $ items , callable $ callback , int $ mode = CALLBACK_USE_VALUE )
117- {
118- $ max = null ;
119- foreach ($ items as $ item ) {
120- $ max = $ item ;
121-
122- break ;
123- }
124-
125- foreach ($ items as $ key => $ value ) {
126- $ value = call_user_func_array ($ callback , __args ($ mode , $ key , $ value ));
127- if ($ value > $ max ) {
128- $ max = $ value ;
129- }
130- }
131-
132- return $ max ;
133- }
134-
135- function min_value (iterable $ items , callable $ callback , int $ mode = CALLBACK_USE_VALUE )
136- {
137- $ min = null ;
138- foreach ($ items as $ item ) {
139- $ min = $ item ;
140-
141- break ;
142- }
143-
144- foreach ($ items as $ key => $ value ) {
145- $ value = call_user_func_array ($ callback , __args ($ mode , $ key , $ value ));
146- if ($ value < $ min ) {
147- $ min = $ value ;
148- }
149- }
150-
151- return $ min ;
152- }
153-
154- function group_by (iterable $ items , callable $ callback , int $ mode = CALLBACK_USE_VALUE ): array
155- {
156- $ group = [];
157- foreach ($ items as $ key => $ value ) {
158- $ group [call_user_func_array ($ callback , __args ($ mode , $ key , $ value ))][] = $ value ;
159- }
160-
161- return $ group ;
162- }
0 commit comments