<?php
namespace WPUltimateSecurity\UltimateSecurity\Modules\Monitoring\SiteHealth\Collectors;

use WPUltimateSecurity\UltimateSecurity\Support\Helpers\Utils;

/**
 * Theme Information Collector
 *
 * Collects theme information using cached data for performance.
 */
class ThemeCollector extends AbstractCollector
{
	/**
	 * Collect theme information
	 *
	 * @return array
	 */
	public function collect(): array
	{
		$current_theme = wp_get_theme();
		$all_themes = Utils::get_themes_cached();
		$parent_theme = $current_theme->parent();

		$data = [
			$this->item(__('Active Theme', 'ultimate-security'), $current_theme->get('Name')),
			$this->item(__('Theme Version', 'ultimate-security'), $current_theme->get('Version')),
			$this->item(__('Theme Author', 'ultimate-security'), $current_theme->get('Author')),
			$this->item(__('Theme URI', 'ultimate-security'), $current_theme->get('ThemeURI')),
			$this->item(__('Total Themes', 'ultimate-security'), count($all_themes)),
		];

		if ($parent_theme) {
			$data[] = $this->item(__('Parent Theme', 'ultimate-security'), $parent_theme->get('Name'));
			$data[] = $this->item(__('Parent Version', 'ultimate-security'), $parent_theme->get('Version'));
		} else {
			$data[] = $this->item(__('Is Child Theme', 'ultimate-security'), false);
		}

		// Add theme directory info
		$data[] = $this->item(__('Theme Directory', 'ultimate-security'), $current_theme->get_stylesheet_directory());
		$data[] = $this->item(__('Theme Template Directory', 'ultimate-security'), $current_theme->get_template_directory());

		return $data;
	}

	/**
	 * Get collector name
	 *
	 * @return string
	 */
	public function getName(): string
	{
		return 'themes';
	}

	/**
	 * Get collector label
	 *
	 * @return string
	 */
	public function getLabel(): string
	{
		return __('Themes', 'ultimate-security');
	}
}
