<?php

declare(strict_types=1);

namespace Drupal\api_monitor_client\Hook;

use Drupal\api_monitor_client\ApiSnifferService;
use Drupal\Core\Hook\Attribute\Hook;

/**
 * Implements hook modules.
 */
class ModuleHook {

  /**
   * Implements hook_theme().
   */
  #[Hook('theme')]
  public function theme(): array {
    return [
      'api_monitor_detail' => [
        'variables' => [
          'api_id' => NULL,
          'provider_id' => NULL,
          'uptime' => 0,
          'avg_latency' => 0,
          'total_checks' => 0,
        ],
      ],
    ];
  }

  /**
   * Executes scheduled tasks registered to be triggered by the cron hook.
   *
   * Implement hook_cron().
   *
   * @return void
   */
  #[Hook('cron')]
  public function cron(): void {
    \Drupal::service('api_monitor_client.sniffer')->runCheck();
  }

}
