# HistoryPanelComparison

> Immutable structural-difference summary for one panel across two captured requests.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Comparison](/docs/extensions/yii3-debug/reference/comparison/index.md) › HistoryPanelComparison

| final readonly class | `Yii3\Debug\Comparison\HistoryPanelComparison` |
| --- | --- |
| Source | [`src/Comparison/HistoryPanelComparison.php`](https://github.com/yii3/debug/blob/main/src/Comparison/HistoryPanelComparison.php#L13) |

Immutable structural-difference summary for one panel across two captured requests.

Counts describe JSON leaf paths only. Captured values are deliberately excluded so the comparison overview cannot
reveal data that the individual panels keep behind their own presentation and redaction rules.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-id"></span>`$id` readonly constructor | `string` | Stable panel ID. | `HistoryPanelComparison` |
| <span id="property-label"></span>`$label` readonly constructor | `string` | Panel display name. | `HistoryPanelComparison` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a comparison summary for one panel across two captures. | `HistoryPanelComparison` |
| [`added()`](#method-added) | Returns the leaves present only in the target capture. | `HistoryPanelComparison` |
| [`baselineState()`](#method-baselineState) | Returns the panel state in the baseline capture. | `HistoryPanelComparison` |
| [`changed()`](#method-changed) | Returns the leaves whose value differs between captures. | `HistoryPanelComparison` |
| [`differenceCount()`](#method-differenceCount) | Returns how many leaves differ between both captures. | `HistoryPanelComparison` |
| [`removed()`](#method-removed) | Returns the leaves present only in the baseline capture. | `HistoryPanelComparison` |
| [`targetState()`](#method-targetState) | Returns the panel state in the target capture. | `HistoryPanelComparison` |
| [`unchanged()`](#method-unchanged) | Returns the leaves identical in both captures. | `HistoryPanelComparison` |
| [`withDifferenceCounts()`](#method-withDifferenceCounts) | Returns a copy carrying different JSON-leaf counts. | `HistoryPanelComparison` |
| [`withStates()`](#method-withStates) | Returns a copy carrying different panel states. | `HistoryPanelComparison` |

## Method details

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

```php
public function __construct(string $id, string $label, Yii3\Debug\Comparison\HistoryPanelStates $states, Yii3\Debug\Comparison\HistoryPanelDifferenceCounts $counts)
```

Creates a comparison summary for one panel across two captures.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `string` | Stable panel ID. |
| `$label` | `string` | Panel display name. |
| `$states` | [`HistoryPanelStates`](/docs/extensions/yii3-debug/reference/comparison/historypanelstates/index.md) | Panel state on each side of the comparison. |
| `$counts` | [`HistoryPanelDifferenceCounts`](/docs/extensions/yii3-debug/reference/comparison/historypaneldifferencecounts/index.md) | JSON-leaf difference counts. |

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

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

Returns the leaves present only in the target capture.

**Returns**

`int`: JSON leaves present only in the target.

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

```php
public function baselineState(): string
```

Returns the panel state in the baseline capture.

**Returns**

`string`: State of the panel in the baseline capture.

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

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

Returns the leaves whose value differs between captures.

**Returns**

`int`: JSON leaves present in both with a different value.

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

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

Returns how many leaves differ between both captures.

**Returns**

`int`: Added, removed, and changed leaves combined; unchanged ones are excluded.

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

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

Returns the leaves present only in the baseline capture.

**Returns**

`int`: JSON leaves present only in the baseline.

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

```php
public function targetState(): string
```

Returns the panel state in the target capture.

**Returns**

`string`: State of the panel in the target capture.

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

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

Returns the leaves identical in both captures.

**Returns**

`int`: JSON leaves identical in both captures.

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

```php
public function withDifferenceCounts(Yii3\Debug\Comparison\HistoryPanelDifferenceCounts $counts): self
```

Returns a copy carrying different JSON-leaf counts.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$counts` | [`HistoryPanelDifferenceCounts`](/docs/extensions/yii3-debug/reference/comparison/historypaneldifferencecounts/index.md) | Counts to apply. |

**Returns**

`self`: Comparison with the counts applied.

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

```php
public function withStates(Yii3\Debug\Comparison\HistoryPanelStates $states): self
```

Returns a copy carrying different panel states.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$states` | [`HistoryPanelStates`](/docs/extensions/yii3-debug/reference/comparison/historypanelstates/index.md) | States to apply. |

**Returns**

`self`: Comparison with the states applied.