| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- /**
- * Report Factory Class - Creates different types of reports
- *
- * @package StudiouWCCustomReports
- */
- if (!defined('ABSPATH')) {
- exit;
- }
- class StudiouWC_Report_Factory {
-
- private $db_manager;
-
- public function __construct($db_manager) {
- $this->db_manager = $db_manager;
- }
-
- public function create_report($type, $data) {
- switch ($type) {
- case 'product_categories_summary':
- return new StudiouWC_Product_Categories_Report($this->db_manager, $data);
- case 'order_customers_list':
- return new StudiouWC_Order_Customers_Report($this->db_manager, $data);
- default:
- /* translators: %s: report type name */
- throw new InvalidArgumentException(sprintf(__('Unknown report type: %s', StudiouWC_Main::get_text_domain()), $type));
- }
- }
- public function get_available_report_types() {
- return array(
- 'product_categories_summary' => __('Product Categories and Variants Summary', StudiouWC_Main::get_text_domain()),
- 'order_customers_list' => __('Order Customers List', StudiouWC_Main::get_text_domain())
- );
- }
-
- public function is_valid_report_type($type) {
- $available_types = array_keys($this->get_available_report_types());
- return in_array($type, $available_types);
- }
- }
|