# PanelComparison

> Compares observed panels in configured order, combining structural differences with capture-state transitions.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Comparison](/docs/extensions/debug-core/reference/comparison/index.md) › PanelComparison

| final readonly class | `PHPForge\Debug\Comparison\PanelComparison` |
| --- | --- |
| Source | [`src/Comparison/PanelComparison.php`](https://github.com/php-forge/debug-core/blob/main/src/Comparison/PanelComparison.php#L21) |

Compares observed panels in configured order, combining structural differences with capture-state transitions.

Results retain only identity, labels, states, and counts; source diagnostics are neither copied nor redacted.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-added"></span>`$added` readonly constructor | `int` | Leaves present only in the target payload. | `PanelComparison` |
| <span id="property-baselineState"></span>`$baselineState` readonly constructor | `string` | Capture state in the baseline snapshot. | `PanelComparison` |
| <span id="property-changed"></span>`$changed` readonly constructor | `int` | Leaves that differ, or `1` for a state-only transition. | `PanelComparison` |
| <span id="property-id"></span>`$id` readonly constructor | `string` | Stable panel ID. | `PanelComparison` |
| <span id="property-label"></span>`$label` readonly constructor | `string` | Display name, falling back to the panel ID. | `PanelComparison` |
| <span id="property-removed"></span>`$removed` readonly constructor | `int` | Leaves present only in the baseline payload. | `PanelComparison` |
| <span id="property-targetState"></span>`$targetState` readonly constructor | `string` | Capture state in the target snapshot. | `PanelComparison` |
| <span id="property-unchanged"></span>`$unchanged` readonly constructor | `int` | Leaves present in both payloads under the same value. | `PanelComparison` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`between()`](#method-between) static | Compares the union of payload and failure IDs, with observed configured IDs first and sorted extras last. | `PanelComparison` |
| [`differenceCount()`](#method-differenceCount) | Returns the total number of structural differences detected for the panel. | `PanelComparison` |

## Constants

| Constant | Value | Description | Defined by |
| --- | --- | --- | --- |
| <span id="const-STATE_CAPTURED"></span>`STATE_CAPTURED` | `'Captured'` | Capture state of a panel whose payload reached the snapshot. | `PanelComparison` |
| <span id="const-STATE_FAILED"></span>`STATE_FAILED` | `'Failed'` | Capture state of a panel whose capture failed. | `PanelComparison` |
| <span id="const-STATE_NOT_CAPTURED"></span>`STATE_NOT_CAPTURED` | `'Not captured'` | Capture state of a panel absent from the snapshot. | `PanelComparison` |

## Method details

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

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

Compares the union of payload and failure IDs, with observed configured IDs first and sorted extras last.

Failures take precedence over payloads. A state transition adds one change only when there are no structural
additions, removals, or changes; unchanged leaves remain counted even for that state-only transition.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$baseline` | [`PHPForge\Debug\Storage\DebugSnapshot`](/docs/extensions/debug-core/reference/storage/debugsnapshot/index.md) | Baseline snapshot. |
| `$target` | [`PHPForge\Debug\Storage\DebugSnapshot`](/docs/extensions/debug-core/reference/storage/debugsnapshot/index.md) | Target snapshot. |
| `$panelLabels` | `array<string, string>` | Display names indexed by stable panel ID, in display order. |

**Returns**

`list<self>`: Panel comparisons in configured display order.

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

```php
public function differenceCount(): int
```

Returns the total number of structural differences detected for the panel.

**Returns**

`int`: Sum of added, removed, and changed leaves.