alleyinteractive / wp-bulk-task

A library to assist with running performant bulk tasks against WordPress database objects.
GNU General Public License v2.0
13 stars 0 forks source link

Add null progress bar #7

Closed dlh01 closed 1 year ago

dlh01 commented 1 year ago

Bulk_Task allows the progress bar to be omitted, but because Progress is an interface, it's also possible to implement the null object pattern. I'd like to be able to use a null progress bar to be able to still use dependency injection in my codebase even when I don't want a progress bar to appear. For example:

new Bulk_Task(
    'audit-blocks',
    get_flag_value( $assoc_args, 'verbose', false )
        ? new PHP_CLI_Progress_Bar( 'Bulk Task: audit-blocks' )
        : new Null_Progress_Bar(),
);

However, since not all codebases rely on DI, I haven't changed the nullable nature of the Progress parameter.