Commit 5a55b18a authored by Erick Hitter's avatar Erick Hitter
Browse files

PHPCS fixes

parent 2372f6de
<?php <?php
/**
* Manage plugin's locks via WP-CLI
*
* @package a8c_Cron_Control
*/
namespace Automattic\WP\Cron_Control\CLI; namespace Automattic\WP\Cron_Control\CLI;
...@@ -11,6 +16,8 @@ class Lock extends \WP_CLI_Command { ...@@ -11,6 +16,8 @@ class Lock extends \WP_CLI_Command {
* *
* @subcommand manage-run-lock * @subcommand manage-run-lock
* @synopsis [--reset] * @synopsis [--reset]
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
*/ */
public function manage_run_lock( $args, $assoc_args ) { public function manage_run_lock( $args, $assoc_args ) {
$lock_name = \Automattic\WP\Cron_Control\Events::LOCK; $lock_name = \Automattic\WP\Cron_Control\Events::LOCK;
...@@ -25,13 +32,15 @@ class Lock extends \WP_CLI_Command { ...@@ -25,13 +32,15 @@ class Lock extends \WP_CLI_Command {
* *
* @subcommand manage-event-lock * @subcommand manage-event-lock
* @synopsis <action> [--reset] * @synopsis <action> [--reset]
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
*/ */
public function manage_event_lock( $args, $assoc_args ) { public function manage_event_lock( $args, $assoc_args ) {
if ( empty( $args[0] ) ) { if ( empty( $args[0] ) ) {
\WP_CLI::error( sprintf( __( 'Specify an action', 'automattic-cron-control' ) ) ); \WP_CLI::error( sprintf( __( 'Specify an action', 'automattic-cron-control' ) ) );
} }
$lock_name = \Automattic\WP\Cron_Control\Events::instance()->get_lock_key_for_event_action( (object) array( 'action' => $args[0], ) ); $lock_name = \Automattic\WP\Cron_Control\Events::instance()->get_lock_key_for_event_action( (object) array( 'action' => $args[0] ) );
$lock_limit = 1; $lock_limit = 1;
$lock_description = __( "This lock prevents concurrent executions of events with the same action, regardless of the action's arguments.", 'automattic-cron-control' ); $lock_description = __( "This lock prevents concurrent executions of events with the same action, regardless of the action's arguments.", 'automattic-cron-control' );
...@@ -40,14 +49,20 @@ class Lock extends \WP_CLI_Command { ...@@ -40,14 +49,20 @@ class Lock extends \WP_CLI_Command {
/** /**
* Retrieve a lock's current value, or reset it * Retrieve a lock's current value, or reset it
*
* @param array $args Array of positional arguments.
* @param array $assoc_args Array of flags.
* @param string $lock_name Name of lock to reset.
* @param int $lock_limit Lock's maximum concurrency.
* @param string $lock_description Human-friendly explanation of lock's purpose.
*/ */
private function get_reset_lock( $args, $assoc_args, $lock_name, $lock_limit, $lock_description ) { private function get_reset_lock( $args, $assoc_args, $lock_name, $lock_limit, $lock_description ) {
// Output information about the lock // Output information about the lock.
\WP_CLI::log( $lock_description . "\n" ); \WP_CLI::log( $lock_description . "\n" );
\WP_CLI::log( sprintf( __( 'Maximum: %s', 'automattic-cron-control' ), number_format_i18n( $lock_limit ) ) . "\n" ); \WP_CLI::log( sprintf( __( 'Maximum: %s', 'automattic-cron-control' ), number_format_i18n( $lock_limit ) ) . "\n" );
// Reset requested // Reset requested.
if ( isset( $assoc_args['reset'] ) ) { if ( isset( $assoc_args['reset'] ) ) {
\WP_CLI::warning( __( 'Resetting lock...', 'automattic-cron-control' ) . "\n" ); \WP_CLI::warning( __( 'Resetting lock...', 'automattic-cron-control' ) . "\n" );
...@@ -65,7 +80,7 @@ class Lock extends \WP_CLI_Command { ...@@ -65,7 +80,7 @@ class Lock extends \WP_CLI_Command {
\WP_CLI::log( __( 'New lock values:', 'automattic-cron-control' ) ); \WP_CLI::log( __( 'New lock values:', 'automattic-cron-control' ) );
} }
// Output lock state // Output lock state.
$lock = \Automattic\WP\Cron_Control\Lock::get_lock_value( $lock_name ); $lock = \Automattic\WP\Cron_Control\Lock::get_lock_value( $lock_name );
$timestamp = \Automattic\WP\Cron_Control\Lock::get_lock_timestamp( $lock_name ); $timestamp = \Automattic\WP\Cron_Control\Lock::get_lock_timestamp( $lock_name );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment