Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Default_Reports | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |
0.00% |
0 / 1 |
| register | |
83.33% |
5 / 6 |
|
0.00% |
0 / 1 |
3.04 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * The package's own reports, handler and provider. |
| 4 | * |
| 5 | * @package automattic/jetpack-woocommerce-stats |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\WooCommerceStats\Report_Execution; |
| 9 | |
| 10 | use Automattic\Jetpack\WooCommerceStats\Api_Proxy_Controller; |
| 11 | |
| 12 | /** |
| 13 | * Registers the reports WordPress.com serves, on `Report_Registry::REGISTER_ACTION`. |
| 14 | * |
| 15 | * @since $$next-version$$ |
| 16 | */ |
| 17 | class Default_Reports { |
| 18 | |
| 19 | /** |
| 20 | * Reports WordPress.com serves, by id => route pattern. |
| 21 | */ |
| 22 | private const ROUTES = array( |
| 23 | 'bookings.by_date' => 'bookings/by-date', |
| 24 | 'coupons' => 'coupons', |
| 25 | 'coupons.by_date' => 'coupons/by-date', |
| 26 | 'customers.by_date' => 'customers/by-date', |
| 27 | 'customers.new_returning' => 'customers/new-returning', |
| 28 | 'order_attribution.compare' => 'order-attribution/[\w-]+/compare', |
| 29 | 'order_attribution.items' => 'order-attribution/[\w-]+/items', |
| 30 | 'order_attribution.summary' => 'order-attribution/[\w-]+/summary', |
| 31 | 'order_attribution_by_product.summary' => 'order-attribution-by-product/[\w-]+/summary', |
| 32 | 'orders.by_date' => 'orders/by-date', |
| 33 | 'orders_by_product_type.by_date' => 'orders-by-product-type/by-date', |
| 34 | 'products' => 'products', |
| 35 | 'sessions.by_conversion_rate' => 'sessions/by-conversion-rate', |
| 36 | 'sessions.by_date' => 'sessions/by-date', |
| 37 | 'sessions.by_device' => 'sessions/by-device', |
| 38 | 'sessions.by_location' => 'sessions/by-location', |
| 39 | 'taxes.breakdown' => 'taxes/breakdown', |
| 40 | 'taxes.by_date' => 'taxes/by-date', |
| 41 | ); |
| 42 | |
| 43 | /** |
| 44 | * Fill the registry. |
| 45 | * |
| 46 | * @param mixed $registry The registry being filled. |
| 47 | * @return void |
| 48 | */ |
| 49 | public static function register( $registry ) { |
| 50 | if ( ! $registry instanceof Report_Registry ) { |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | $registry->register_provider( 'wpcom', new Wpcom_Report_Provider() ); |
| 55 | $registry->register_handler( Report_Registry::ANY_REPORT, 'wpcom', new Wpcom_Forward_Handler( new Api_Proxy_Controller() ) ); |
| 56 | |
| 57 | foreach ( self::ROUTES as $id => $route ) { |
| 58 | $registry->register_report( new Report_Definition( $id, 0, array( $route ) ) ); |
| 59 | } |
| 60 | } |
| 61 | } |