* : First day, Y-m-d, in the site's timezone. * * --to= * : Last day, Y-m-d, inclusive. * * ## EXAMPLES * * wp rahkar sms-count --from=2026-10-01 --to=2026-10-07 * * @param list $args Positional arguments; none. * @param array $assoc Named arguments. */ public static function run( array $args, array $assoc ): void { unset( $args ); $zone = wp_timezone(); $from = \DateTimeImmutable::createFromFormat( '!Y-m-d', (string) ( $assoc['from'] ?? '' ), $zone ); $to = \DateTimeImmutable::createFromFormat( '!Y-m-d', (string) ( $assoc['to'] ?? '' ), $zone ); if ( false === $from || false === $to || $to < $from ) { \WP_CLI::error( 'Give --from and --to as Y-m-d, with --to on or after --from.' ); } $start = $from->getTimestamp(); $end = $to->modify( '+1 day' )->getTimestamp() - 1; $found = false; foreach ( Gateways::enabled() as $driver ) { if ( ! $driver instanceof ReportingDriver ) { continue; } $found = true; $count = $driver->sentCount( $start, $end ); if ( is_string( $count ) ) { \WP_CLI::warning( $driver->id() . ': ' . $count ); continue; } \WP_CLI::line( sprintf( '%s: %d messages sent from %s to %s', $driver->id(), $count, $from->format( 'Y-m-d' ), $to->format( 'Y-m-d' ) ) ); } if ( ! $found ) { \WP_CLI::warning( 'No enabled gateway can report sent messages.' ); } } }