# HistoryMetricComparison

> Immutable presentation data for one request-summary metric in a capture comparison.

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

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

Immutable presentation data for one request-summary metric in a capture comparison.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-label"></span>`$label` readonly constructor | `string` | Human-readable metric name. | `HistoryMetricComparison` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`baseline()`](#method-baseline) | Returns the formatted value of the baseline capture. | `HistoryMetricComparison` |
| [`create()`](#method-create) static | Creates a metric that can be fluently linked with [`withPanelId()`](/docs/extensions/yii3-debug/reference/comparison/historymetriccomparison/index.md#method-withPanelId). | `HistoryMetricComparison` |
| [`delta()`](#method-delta) | Returns the formatted difference between both captures. | `HistoryMetricComparison` |
| [`panelId()`](#method-panelId) | Returns the panel this metric deep-links to. | `HistoryMetricComparison` |
| [`target()`](#method-target) | Returns the formatted value of the target capture. | `HistoryMetricComparison` |
| [`trend()`](#method-trend) | Returns the direction the metric moved in. | `HistoryMetricComparison` |
| [`withPanelId()`](#method-withPanelId) | Returns a copy deep-linking the metric to a panel. | `HistoryMetricComparison` |

## Method details

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

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

Returns the formatted value of the baseline capture.

**Returns**

`string`: Formatted baseline value.

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

```php
public static function create(string $label, Yii3\Debug\Comparison\HistoryMetricValues $values): self
```

Creates a metric that can be fluently linked with [`withPanelId()`](/docs/extensions/yii3-debug/reference/comparison/historymetriccomparison/index.md#method-withPanelId).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$label` | `string` | Human-readable metric name. |
| `$values` | [`HistoryMetricValues`](/docs/extensions/yii3-debug/reference/comparison/historymetricvalues/index.md) | Formatted values and outcome of the metric. |

**Returns**

`self`: Metric without a panel link.

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

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

Returns the formatted difference between both captures.

**Returns**

`string`: Formatted difference from baseline to target.

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

```php
public function panelId(): string|null
```

Returns the panel this metric deep-links to.

**Returns**

`string|null`: Panel the metric deep-links to, or `null` when it links nowhere.

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

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

Returns the formatted value of the target capture.

**Returns**

`string`: Formatted target value.

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

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

Returns the direction the metric moved in.

**Returns**

`string`: Directional CSS vocabulary: `'up'`, `'down'`, or `'neutral'`.

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

```php
public function withPanelId(string|null $panelId): self
```

Returns a copy deep-linking the metric to a panel.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$panelId` | `string\|null` | Panel to link to, or `null` to drop the link. |

**Returns**

`self`: Metric with the link applied.