<?php
/**
 * JSON response test double.
 *
 * @package GravityOps\Core
 */

/**
 * Throwable JSON response used by AJAX tests.
 */
class TestJsonResponse extends RuntimeException {

	/**
	 * Whether the response represents success.
	 *
	 * @var bool
	 */
	public bool $success;

	/**
	 * Constructor.
	 *
	 * @param array $data    Response data.
	 * @param int   $status  HTTP status.
	 * @param bool  $success Whether the response succeeded.
	 */
	public function __construct( array $data, int $status, bool $success ) {
		parent::__construct( (string) ( $data['message'] ?? '' ), $status );
		$this->success = $success;
	}
}
