# ToolbarItem

> Represents one metric rendered inside a debug toolbar panel.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Toolbar](/docs/extensions/debug-core/reference/toolbar/index.md) › ToolbarItem

| final readonly class | `PHPForge\Debug\Toolbar\ToolbarItem` |
| --- | --- |
| Implements | [`JsonSerializable`](https://www.php.net/manual/en/class.jsonserializable.php) |
| Source | [`src/Toolbar/ToolbarItem.php`](https://github.com/php-forge/debug-core/blob/main/src/Toolbar/ToolbarItem.php#L14) |

Represents one metric rendered inside a debug toolbar panel.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-icon"></span>`$icon` readonly constructor | `string\|null` | Shared icon name or `null` when the label identifies the value. Default: `null`. | `ToolbarItem` |
| <span id="property-id"></span>`$id` readonly constructor | `string\|null` | Stable semantic metric identifier or `null` for presentation-only metrics. Default: `null`. | `ToolbarItem` |
| <span id="property-label"></span>`$label` readonly constructor | `string\|null` | Short metric label or `null` when an icon identifies the value. Default: `null`. | `ToolbarItem` |
| <span id="property-status"></span>`$status` readonly constructor | `string` | Semantic badge status. Default: `'default'`. | `ToolbarItem` |
| <span id="property-title"></span>`$title` readonly constructor | `string\|null` | Tooltip text or `null` when no tooltip is needed. Default: `null`. | `ToolbarItem` |
| <span id="property-url"></span>`$url` readonly constructor | `string\|null` | Debug page URL or `null` when the metric is not navigable. Default: `null`. | `ToolbarItem` |
| <span id="property-value"></span>`$value` readonly constructor | `string` | Metric value shown in the toolbar. | `ToolbarItem` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`create()`](#method-create) static | Creates a metric with default presentation options. | `ToolbarItem` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the metric payload consumed by the toolbar runtime. | `ToolbarItem` |
| [`withIcon()`](#method-withIcon) | Returns a copy with the specified icon. | `ToolbarItem` |
| [`withId()`](#method-withId) | Returns a copy with the specified metric ID. | `ToolbarItem` |
| [`withLabel()`](#method-withLabel) | Returns a copy with the specified label. | `ToolbarItem` |
| [`withStatus()`](#method-withStatus) | Returns a copy with the specified status. | `ToolbarItem` |
| [`withTitle()`](#method-withTitle) | Returns a copy with the specified title. | `ToolbarItem` |
| [`withUrl()`](#method-withUrl) | Returns a copy with the specified URL. | `ToolbarItem` |

## Method details

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

```php
public static function create(string $value): self
```

Creates a metric with default presentation options.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` |  |

**Returns**

`self`

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

```php
public function jsonSerialize(): array{value: string, status: string, label?: string, icon?: string, title?: string, url?: string, id?: string}
```

Returns the metric payload consumed by the toolbar runtime.

**Returns**

`array{value: string, status: string, label?: string, icon?: string, title?: string, url?: string, id?: string}`: Serialized metric payload.

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

```php
public function withIcon(string|null $icon): self
```

Returns a copy with the specified icon.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$icon` | `string\|null` |  |

**Returns**

`self`

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

```php
public function withId(string|null $id): self
```

Returns a copy with the specified metric ID.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$id` | `string\|null` |  |

**Returns**

`self`

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

```php
public function withLabel(string|null $label): self
```

Returns a copy with the specified label.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$label` | `string\|null` |  |

**Returns**

`self`

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

```php
public function withStatus(string $status): self
```

Returns a copy with the specified status.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$status` | `string` |  |

**Returns**

`self`

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

```php
public function withTitle(string|null $title): self
```

Returns a copy with the specified title.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$title` | `string\|null` |  |

**Returns**

`self`

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

```php
public function withUrl(string|null $url): self
```

Returns a copy with the specified URL.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$url` | `string\|null` |  |

**Returns**

`self`