public static function _apply_stats($value, array &$args, HandlerList $list) { // Create an array of stat collectors that are disabled (set to false) // by default. If the user has passed in true, enable all stat // collectors. $defaults = array_fill_keys(['http', 'retries', 'timer'], $value === true); $args['stats'] = is_array($value) ? array_replace($defaults, $value) : $defaults; if ($args['stats']['timer']) { $list->prependInit(Middleware::timer(), 'timer'); } }