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.31
Disabled: pcntl_fork
Upload Files
File: /wordpress/plugins/wp-cloud-client/beta/src/Handler/GetDebugStatusHandler.php
<?php

declare(strict_types=1);

namespace VPlugins\WPCloudClient\Handler;

use VPlugins\WPCloudClient\Debug\WpConfigEditor;

final class GetDebugStatusHandler extends AbstractHandler {

	/**
	 * Class constructor.
	 *
	 * @param WpConfigEditor $editor wp-config.php editor service.
	 */
	public function __construct(
		private readonly WpConfigEditor $editor,
	) {}

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

	/**
	 * Return the current state of all WP debug constants.
	 *
	 * @param array<string, mixed> $params Unused.
	 * @return array<string, mixed> Current debug constant values.
	 *
	 * @throws \RuntimeException If wp-config.php cannot be read.
	 */
	public function execute( array $params ): array {
		$constants = $this->editor->getConstants();

		return [
			'wp_debug'         => $constants['WP_DEBUG'] ?? false,
			'wp_debug_log'     => $constants['WP_DEBUG_LOG'] ?? false,
			'wp_debug_display' => $constants['WP_DEBUG_DISPLAY'] ?? false,
			'script_debug'     => $constants['SCRIPT_DEBUG'] ?? false,
		];
	}
}