class-report-factory.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Report Factory Class - Creates different types of reports
  4. *
  5. * @package StudiouWCCustomReports
  6. */
  7. if (!defined('ABSPATH')) {
  8. exit;
  9. }
  10. class StudiouWC_Report_Factory {
  11. private $db_manager;
  12. public function __construct($db_manager) {
  13. $this->db_manager = $db_manager;
  14. }
  15. public function create_report($type, $data) {
  16. switch ($type) {
  17. case 'product_categories_summary':
  18. return new StudiouWC_Product_Categories_Report($this->db_manager, $data);
  19. default:
  20. throw new InvalidArgumentException("Unknown report type: $type");
  21. }
  22. }
  23. public function get_available_report_types() {
  24. return array(
  25. 'product_categories_summary' => __('Product Categories and Variants Summary', StudiouWC_Main::get_text_domain())
  26. );
  27. }
  28. public function is_valid_report_type($type) {
  29. $available_types = array_keys($this->get_available_report_types());
  30. return in_array($type, $available_types);
  31. }
  32. }