HEX
Server: nginx
System: Linux pool195-106-36.bur.atomicsites.net 6.12.57+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1~bpo12+1 (2025-11-17) x86_64
User: (0)
PHP: 8.3.32
Disabled: pcntl_fork
Upload Files
File: /wordpress/plugins/wp-cloud-client/1.1.6/src/Handler/HealthCheckHandler.php
<?php

declare(strict_types=1);

namespace VPlugins\WPCloudClient\Handler;

use VPlugins\WPCloudClient\Settings\SettingsRepository;
use VPlugins\WPCloudClient\Support\Clock;

final class HealthCheckHandler extends AbstractHandler {

	/**
	 * Class constructor.
	 *
	 * @param SettingsRepository $settings Settings repository.
	 * @param Clock              $clock    Clock instance.
	 */
	public function __construct(
		private readonly SettingsRepository $settings,
		private readonly Clock $clock,
	) {}

	/**
	 * Return the action name.
	 *
	 * @return string Action name.
	 */
	public function action(): string {
		return 'health_check';
	}

	/**
	 * Perform a health check and return diagnostic data.
	 *
	 * @param array<string, mixed> $params Action parameters.
	 * @return array<string, mixed> Health check result.
	 */
	public function execute( array $params ): array {
		global $wpdb;

		$dbOk = (bool) $wpdb->get_var( 'SELECT 1' );

		return [
			'healthy'        => $dbOk,
			'wp_version'     => get_bloginfo( 'version' ),
			'php_version'    => PHP_VERSION,
			'plugin_version' => VPLUGINS_WPCC_VERSION,
			'site_id'        => $this->settings->getSiteId(),
			'environment'    => $this->settings->getEnvironment(),
			'timestamp'      => $this->clock->iso8601(),
			'checks'         => [
				'database'   => $dbOk ? 'ok' : 'error',
				'filesystem' => wp_is_writable( WP_CONTENT_DIR ) ? 'ok' : 'warning',
			],
		];
	}
}