Completed
Push — 677-feature/add-wp-cli-support ( a6bca4...1a74d2 )
by Sudar
03:32
created

DeletePostsCommand::validate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 3
eloc 5
c 2
b 1
f 0
nc 3
nop 2
dl 0
loc 10
ccs 0
cts 8
cp 0
crap 12
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\Posts\Modules\DeletePostsByStatusModule;
7
8
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
9
10
/**
11
 * Delete Posts CLI Command.
12
 *
13
 * @since 6.1.0
14
 */
15
class DeletePostsCommand extends BaseCommand {
16
	/**
17
	 * Get the command.
18
	 *
19
	 * @return string Command name.
20
	 */
21
	public static function get_command() {
22
		return 'posts';
23
	}
24
25
	/**
26
	 * Delete post by status.
27
	 *
28
	 * ## OPTIONS
29
	 *
30
	 * [--post_status=<post_status>]
31
	 * : Comma seperated list of post status from which posts should be deleted. You can also use any custom post status.
32
	 * ---
33
	 * options:
34
	 *   - publish (default)
35
	 *   - draft,publish
36
	 *   - draft,publish,private
37
	 *   - private
38
	 * ---
39
	 *
40
	 * [--limit_to=<limit_to>]
41
	 * : Limits the number of posts to be deleted.
42
	 *
43
	 * [--restrict=<restrict>]
44
	 * : Restricts posts deletion with post date filter.
45
	 * ---
46
	 * default: false
47
	 * options:
48
	 *   - true
49
	 *   - false
50
	 * ---
51
	 *
52
	 * [--force_delete=<force_delete>]
53
	 * : True for permanent deletion and false for moving to trash.
54
	 * ---
55
	 * default: false
56
	 * options:
57
	 *   - true
58
	 *   - false
59
	 * ---
60
	 *
61
	 * @subcommand by-status
62
	 *
63
	 * @param array $args       Arguments to be supplied.
64
	 * @param array $assoc_args Associative arguments to be supplied.
65
	 *
66
	 * @return void
67
	 */
68
	public function by_status( $args, $assoc_args ) {
69
		$module = new DeletePostsByStatusModule();
70
71
		$message = $module->process_cli_request( $assoc_args );
72
73
		\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...
74
	}
75
}
76