<?php
/**
 * Class InstanceSettingsAssets
 *
 * @package DhlPolska\ShippingMethod
 */

namespace DhlPolska\ShippingMethod;

use DhlPolskaVendor\WPDesk\PluginBuilder\Plugin\Hookable;

/**
 * Adds scripts for DHL instance settings.
 */
class InstanceSettingsAssets implements Hookable {

	/**
	 * @return void
	 */
	public function hooks() {
		add_action( 'admin_footer', [ $this, 'render_scripts' ] );
	}

	/**
	 * @return void
	 */
	public function render_scripts() {
		if ( ! $this->is_shipping_settings_screen() ) {
			return;
		}

		include __DIR__ . '/views/html-instance-settings-scripts.php';
	}

	private function is_shipping_settings_screen(): bool {
		$page = filter_input( INPUT_GET, 'page' );
		$tab  = filter_input( INPUT_GET, 'tab' );

		return 'wc-settings' === $page && 'shipping' === $tab;
	}
}
