Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Utilities
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 is_comparison_request
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * Utilities trait.
4 *
5 * Trimmed for the Premium Analytics report-export port: only the helper the export
6 * subsystem actually uses is kept. The original WooCommerce Analytics trait carried
7 * asset/CDN, HPOS, and order-attribution helpers that pulled in WooCommerce-internal
8 * classes; those are not needed here.
9 *
10 * @package Automattic\Jetpack\PremiumAnalytics\Reports\Export\Support
11 */
12
13declare( strict_types=1 );
14
15namespace Automattic\Jetpack\PremiumAnalytics\Reports\Export\Support;
16
17defined( 'ABSPATH' ) || exit;
18
19/**
20 * Shared helpers for the report-export subsystem.
21 *
22 * @since 0.1.0
23 */
24trait Utilities {
25
26    /**
27     * Check if the given parameters indicate a comparison request.
28     *
29     * @param array $params Request parameters.
30     * @return bool True if both compare_from and compare_to are present and not empty.
31     */
32    protected function is_comparison_request( array $params ): bool {
33        return ! empty( $params['compare_from'] ) && ! empty( $params['compare_to'] );
34    }
35}