# AssetUtil

> Reads and normalizes asset metadata exposed by Composer packages.

[API reference](/docs/api/index.md) › [Foxy](/docs/extensions/foxy/reference/index.md) › [Util](/docs/extensions/foxy/reference/util/index.md) › AssetUtil

| final class | `Foxy\Util\AssetUtil` |
| --- | --- |
| Source | [`src/Util/AssetUtil.php`](https://github.com/php-forge/foxy/blob/main/src/Util/AssetUtil.php#L32) |

Reads and normalizes asset metadata exposed by Composer packages.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`formatPackage()`](#method-formatPackage) static | Format the asset package. | `AssetUtil` |
| [`getName()`](#method-getName) static | Get the name for the asset dependency. | `AssetUtil` |
| [`getPath()`](#method-getPath) static | Get the path of asset file. | `AssetUtil` |
| [`hasExtraActivation()`](#method-hasExtraActivation) static | Check if foxy is enabled in extra section of package. | `AssetUtil` |
| [`hasPluginDependency()`](#method-hasPluginDependency) static | Check if the package contains assets. | `AssetUtil` |
| [`isAsset()`](#method-isAsset) static | Check if the package is available for Foxy. | `AssetUtil` |
| [`isProjectActivation()`](#method-isProjectActivation) static | Check if the package is enabled by the project config. | `AssetUtil` |

## Method details

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

```php
public static function formatPackage(Composer\Package\PackageInterface $package, string $packageName, array $packageValue): array
```

Format the asset package.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$package` | `Composer\Package\PackageInterface` | The composer package instance. |
| `$packageName` | `string` | The package name of asset. |
| `$packageValue` | `array` | The package value of asset. |

**Returns**

`array`

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

```php
public static function getName(Composer\Package\PackageInterface $package): string
```

Get the name for the asset dependency.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$package` | `Composer\Package\PackageInterface` | The package instance. |

**Returns**

`string`

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

```php
public static function getPath(Composer\Installer\InstallationManager $installationManager, Foxy\Asset\AssetManagerInterface $assetManager, Composer\Package\PackageInterface $package, array $configPackages = []): string|null
```

Get the path of asset file.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$installationManager` | `Composer\Installer\InstallationManager` | The installation manager. |
| `$assetManager` | [`Foxy\Asset\AssetManagerInterface`](/docs/extensions/foxy/reference/asset/assetmanagerinterface/index.md) | The asset manager. |
| `$package` | `Composer\Package\PackageInterface` | The package instance. |
| `$configPackages` | `array` | The packages defined in config. |

**Returns**

`string|null`

**Throws**

- [`JsonException`](https://www.php.net/manual/en/class.jsonexception.php)

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

```php
public static function hasExtraActivation(Composer\Package\PackageInterface $package): bool
```

Check if foxy is enabled in extra section of package.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$package` | `Composer\Package\PackageInterface` | The package instance. |

**Returns**

`bool`

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

```php
public static function hasPluginDependency(Composer\Package\Link[] $requires): bool
```

Check if the package contains assets.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$requires` | `Composer\Package\Link[]` | The requirement links. |

**Returns**

`bool`

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

```php
public static function isAsset(Composer\Package\PackageInterface $package, array $configPackages = []): bool
```

Check if the package is available for Foxy.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$package` | `Composer\Package\PackageInterface` | The package instance. |
| `$configPackages` | `array` | The packages defined in config. |

**Returns**

`bool`

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

```php
public static function isProjectActivation(Composer\Package\PackageInterface $package, array $configPackages): bool
```

Check if the package is enabled by the project config.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$package` | `Composer\Package\PackageInterface` | The package instance. |
| `$configPackages` | `array` | The packages defined in config. |

**Returns**

`bool`