# AssetBundleRow

> Typed asset-bundle row narrowed once from the live yii\web\AssetBundle and persisted in that form.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Asset](/docs/extensions/debug-core/reference/panel/asset/index.md) › AssetBundleRow

| final readonly class | `PHPForge\Debug\Panel\Asset\AssetBundleRow` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelRow`](/docs/extensions/debug-core/reference/storage/panelrow/index.md) |
| Source | [`src/Panel/Asset/AssetBundleRow.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Asset/AssetBundleRow.php#L17) |

Typed asset-bundle row narrowed once from the live [`AssetBundle`](/docs/api/yii/web/assetbundle/index.md) and persisted in that form.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-basePath"></span>`$basePath` readonly constructor | `string` | Published base path, or `''` when the bundle was never published. | `AssetBundleRow` |
| <span id="property-baseUrl"></span>`$baseUrl` readonly constructor | `string` | Published base URL, or `''` when the bundle was never published. | `AssetBundleRow` |
| <span id="property-css"></span>`$css` readonly constructor | `list<string>` | CSS files declared by the bundle. | `AssetBundleRow` |
| <span id="property-depends"></span>`$depends` readonly constructor | `list<string>` | Bundle class names this bundle depends on. | `AssetBundleRow` |
| <span id="property-js"></span>`$js` readonly constructor | `list<string>` | JavaScript files declared by the bundle. | `AssetBundleRow` |
| <span id="property-name"></span>`$name` readonly constructor | `string` | Bundle class name as registered on the asset manager. | `AssetBundleRow` |
| <span id="property-sourcePath"></span>`$sourcePath` readonly constructor | `string` | Source path declared by the bundle, or `''` when it publishes nothing. | `AssetBundleRow` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates an asset-bundle row from its captured metadata. | `AssetBundleRow` |
| [`fromArray()`](#method-fromArray) static | Narrows one persisted bundle of the asset payload into a typed row. | `AssetBundleRow` |
| [`fromBundle()`](#method-fromBundle) static | Narrows one live asset bundle into a typed row. | `AssetBundleRow` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the typed row for JSON serialization. | `AssetBundleRow` |

## Method details

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

```php
public function __construct(string $name, string $sourcePath, string $basePath, string $baseUrl, array $css, array $js, array $depends)
```

Creates an asset-bundle row from its captured metadata.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` |  |
| `$sourcePath` | `string` |  |
| `$basePath` | `string` |  |
| `$baseUrl` | `string` |  |
| `$css` | `array` |  |
| `$js` | `array` |  |
| `$depends` | `array` |  |

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

```php
public static function fromArray(mixed $data, string $path): self
```

Narrows one persisted bundle of the asset payload into a typed row.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Persisted bundle, expected to be an object carrying the declared shape. |
| `$path` | `string` | JSON path of the bundle, used to report a malformed payload. |

**Returns**

`self`: Row carrying every persisted bundle field.

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

```php
public static function fromBundle(string $name, array<array-key, mixed> $bundle): self
```

Narrows one live asset bundle into a typed row.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` |  |
| `$bundle` | `array<array-key, mixed>` | Serialized bundle properties. |

**Returns**

`self`

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

```php
public function jsonSerialize(): array<string, mixed>
```

Returns the typed row for JSON serialization.

**Returns**

`array<string, mixed>`