<?php
/**
 * Resolved Extension catalog report.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Extension;

/** Immutable Extension catalog result. */
final class ExtensionCatalogReport {
	/** @var ExtensionDefinition[] */
	private array $definitions;
	/** @var string[] */
	private array $errors;

	/**
	 * Creates a resolved Extension report.
	 *
	 * @param ExtensionDefinition[] $definitions Selected Extensions.
	 * @param string[]              $errors Resolution errors.
	 */
	public function __construct( array $definitions, array $errors = array() ) {
		$this->definitions = array_values( $definitions );
		$this->errors      = array_values( array_unique( $errors ) );
	}

	/** @return ExtensionDefinition[] */
	public function definitions(): array {
		return $this->definitions; }
	/** @return string[] */
	public function errors(): array {
		return $this->errors; }
	public function healthy(): bool {
		return array() === $this->errors; }
}
