# HistoryComparison

> Builds a privacy-preserving comparison of two immutable debugger snapshots.

[API reference](/docs/api/index.md) › [Debug](/docs/extensions/debug/reference/index.md) › [widgets](/docs/extensions/debug/reference/widgets/index.md) › [history](/docs/extensions/debug/reference/widgets/history/index.md) › HistoryComparison

| final readonly class | `yii\debug\widgets\history\HistoryComparison` |
| --- | --- |
| Source | [`src/widgets/history/HistoryComparison.php`](https://github.com/yii2-extensions/debug/blob/main/src/widgets/history/HistoryComparison.php#L16) |

Builds a privacy-preserving comparison of two immutable debugger snapshots.

Summary metrics expose already-redacted manifest data. Panel payloads are compared structurally, retaining only
counts of added, removed, changed, and unchanged JSON leaves instead of copying their values into the overview.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-baseline"></span>`$baseline` readonly | `PHPForge\Debug\Storage\DebugSnapshot` | Baseline snapshot. | `HistoryComparison` |
| <span id="property-metrics"></span>`$metrics` readonly | `list<PHPForge\Debug\Comparison\SummaryMetricComparison>` | Request-summary metric comparisons in canonical history order. | `HistoryComparison` |
| <span id="property-panels"></span>`$panels` readonly | `list<PHPForge\Debug\Comparison\PanelComparison>` | Per-panel structural comparisons in configured display order. | `HistoryComparison` |
| <span id="property-target"></span>`$target` readonly | `PHPForge\Debug\Storage\DebugSnapshot` | Target snapshot. | `HistoryComparison` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`fromSnapshots()`](#method-fromSnapshots) static | Creates a comparison from two snapshots. | `HistoryComparison` |
| [`hasDifferences()`](#method-hasDifferences) | Returns whether either summary metrics or panel payloads differ. | `HistoryComparison` |

## Method details

### fromSnapshots() <span id="method-fromSnapshots"></span>

```php
public static function fromSnapshots(PHPForge\Debug\Storage\DebugSnapshot $baseline, PHPForge\Debug\Storage\DebugSnapshot $target, array<string, string> $panelLabels = []): self
```

Creates a comparison from two snapshots.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$baseline` | `PHPForge\Debug\Storage\DebugSnapshot` | Capture used as the reference side of the comparison. |
| `$target` | `PHPForge\Debug\Storage\DebugSnapshot` | Capture compared against the baseline. |
| `$panelLabels` | `array<string, string>` | Display names indexed by stable panel ID. |

**Returns**

`self`: Comparison holding the metric and panel differences between both captures.

### hasDifferences() <span id="method-hasDifferences"></span>

```php
public function hasDifferences(): bool
```

Returns whether either summary metrics or panel payloads differ.

**Returns**

`bool`: `true` when metrics or panel payloads differ; `false` when the captures match.