Passed
Push — 677-feature/add-wp-cli-support ( 6de45b...2d7fc5 )
by
unknown
05:14
created

DeleteTermsCommand::by_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
3
namespace BulkWP\BulkDelete\Core\CLI\Commands;
4
5
use BulkWP\BulkDelete\Core\Base\BaseCommand;
6
use BulkWP\BulkDelete\Core\Terms\Modules\DeleteTermsByNameModule;
7
8
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
9
10
/**
11
 * Delete Terms CLI Command.
12
 *
13
 * @since 6.1.0
14
 */
15
class DeleteTermsCommand extends BaseCommand {
16
	/**
17
	 * Get the command.
18
	 *
19
	 * @return string Command name.
20
	 */
21
	public static function get_command() {
22
		return 'terms';
23
	}
24
25
	/**
26
	 * Delete terms by name.
27
	 *
28
	 * ## OPTIONS
29
	 *
30
	 * [--taxonomy=<taxonomy>]
31
	 * : Taxonomy the term going to be deleted belongs to. You can use any custom taxonomy.
32
	 * ---
33
	 * default: category
34
	 * ---
35
	 *
36
	 * [--operator=<operator>]
37
	 * : Comparison operator for name to compare with.
38
	 * ---
39
	 * default: =
40
	 * options:
41
	 *   - =
42
	 *   - !=
43
	 *   - LIKE
44
	 *   - NOT LIKE
45
	 *   - STARTS_WITH
46
	 *   - ENDS_WITH
47
	 * ---
48
	 *
49
	 * --value=<value>
50
	 * : Term name
51
	 *
52
	 *  ## EXAMPLES
53
	 *
54
	 *     # Delete terms with name fruit under category taxonomy.
55
	 *     $ wp bulk-delete terms by-name --value=fruit
56
	 *     Success: Deleted 10 terms with the selected options
57
	 *
58
	 *     # Delete terms with name containing apple under product_cat(custom taxonomy) taxonomy.
59
	 *     $ wp bulk-delete terms by-name --taxonomy=product_cat --operator=LIKE --value=apple
60
	 *     Success: Deleted 5 terms with the selected options
61
	 *
62
	 *     # Delete terms with name ends with apple under post tag taxonomy.
63
	 *     $ wp bulk-delete terms by-name --taxonomy=post_tag --operator=ENDS_WITH --value=apple
64
	 *     Success: Deleted 3 terms with the selected options
65
	 *
66
	 * @subcommand by-name
67
	 *
68
	 * @param array $args       Arguments to be supplied.
69
	 * @param array $assoc_args Associative arguments to be supplied.
70
	 *
71
	 * @return void
72
	 */
73
	public function by_name( $args, $assoc_args ) {
74
		$module = new DeleteTermsByNameModule();
75
76
		$message = $module->process_cli_request( $assoc_args );
77
78
		\WP_CLI::success( $message );
0 ignored issues
show
Bug introduced by
The type WP_CLI was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
79
	}
80
}
81