<?php
/**
 * Launch lifecycle application result.
 *
 * @package ScheduledChanges
 */

namespace ScheduledChanges\Application;

/**
 * Carries stable application success codes and neutral payloads.
 */
final class LaunchLifecycleResult {
	private string $code;
	/**
	 * @var array<string,mixed>
	 */
	private array $data;

	/**
	 * @param array<string,mixed> $data Result payload.
	 */
	private function __construct( string $code, array $data ) {
		$this->code = $code;
		$this->data = $data;
	}

	/**
	 * Creates a successful result.
	 *
	 * @param array<string,mixed> $data Result payload.
	 */
	public static function success( string $code, array $data = array() ): self {
		return new self( $code, $data );
	}

	/**
	 * Returns the stable success code.
	 */
	public function code(): string {
		return $this->code;
	}

	/**
	 * Returns the neutral payload.
	 *
	 * @return array<string,mixed>
	 */
	public function data(): array {
		return $this->data;
	}
}
