public function list_( $args, $assoc_args ) {

		global $wpdb;
		$pattern    = '%';
		$fields     = [ 'meta_key', 'meta_value' ];
		$size_query = ',LENGTH(meta_value) AS `size_bytes`';

		if ( isset( $assoc_args['search'] ) ) {
			$pattern = self::esc_like( $assoc_args['search'] );
			// substitute wildcards
			$pattern = str_replace( '*', '%', $pattern );
			$pattern = str_replace( '?', '_', $pattern );
		}

		if ( isset( $assoc_args['fields'] ) ) {
			$fields = explode( ',', $assoc_args['fields'] );
		}

		if ( Utils\get_flag_value( $assoc_args, 'format' ) === 'total_bytes' ) {
			$fields     = [ 'size_bytes' ];
			$size_query = ',SUM(LENGTH(meta_value)) AS `size_bytes`';
		}

		$query = $wpdb->prepare(
			'SELECT `meta_id`, `site_id`, `meta_key`,`meta_value`'
				. $size_query // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Hard-coded partial query without user input.
				. " FROM `$wpdb->sitemeta` WHERE `meta_key` LIKE %s",
			$pattern
		);

		$site_id = Utils\get_flag_value( $assoc_args, 'site_id' );
		if ( $site_id ) {
			$query .= $wpdb->prepare( ' AND site_id=%d', $site_id );
		}
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- $query is already prepared above.
		$results = $wpdb->get_results( $query );

		if ( Utils\get_flag_value( $assoc_args, 'format' ) === 'total_bytes' ) {
			WP_CLI::line( $results[0]->size_bytes );
		} else {
			$formatter = new Formatter(
				$assoc_args,
				$fields
			);
			$formatter->display_items( $results );
		}
	}