<?php
/**
 * Configured detector bundle.
 *
 * @package LocalGuardScanner
 */

namespace LocalGuardScanner\Detection;

use LocalGuardScanner\Detection\Plugin\PluginAdvisory;

/**
 * Carries the engine and the coverage metadata used to construct it.
 */
final class DetectorBundle {
	/** @var DetectorEngine */
	private $engine;
	/** @var string */
	private $rules_version;
	/** @var bool */
	private $core_manifest_available;
	/** @var array<string,string>|null */
	private $core_manifest;
	/** @var PluginAdvisory[] */
	private $plugin_advisories;
	/** @var string */
	private $advisory_date;

	/**
	 * @param DetectorEngine $engine                  Engine.
	 * @param string         $rules_version           Rule version.
	 * @param bool                      $core_manifest_available Exact manifest availability.
	 * @param array<string,string>|null $core_manifest           Exact core hashes.
	 * @param PluginAdvisory[]          $plugin_advisories       Signed plugin advisories.
	 * @param string                    $advisory_date            Advisory compilation date.
	 */
	public function __construct( DetectorEngine $engine, $rules_version, $core_manifest_available, $core_manifest = null, array $plugin_advisories = array(), $advisory_date = '' ) {
		$this->engine                  = $engine;
		$this->rules_version           = $rules_version;
		$this->core_manifest_available = (bool) $core_manifest_available;
		$this->core_manifest           = is_array( $core_manifest ) ? $core_manifest : null;
		$this->plugin_advisories       = $plugin_advisories;
		$this->advisory_date           = $advisory_date;
	}

	/** @return DetectorEngine */
	public function engine() {
		return $this->engine;
	}

	/** @return string */
	public function rules_version() {
		return $this->rules_version;
	}

	/** @return bool */
	public function core_manifest_available() {
		return $this->core_manifest_available;
	}

	/** @return array<string,string>|null */
	public function core_manifest() {
		return $this->core_manifest;
	}

	/** @return PluginAdvisory[] */
	public function plugin_advisories() {
		return $this->plugin_advisories;
	}

	/** @return string */
	public function advisory_date() {
		return $this->advisory_date;
	}
}
