# PackageUtil

> Hydrates Composer package records stored in lock data.

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

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

Hydrates Composer package records stored in lock data.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`loadLockPackage()`](#method-loadLockPackage) static | Load the packages in the packages section of the locker load data. | `PackageUtil` |
| [`loadLockPackages()`](#method-loadLockPackages) static | Loads the `packages` and `packages-dev` entries of the lock data, leaving every other key unchanged. | `PackageUtil` |

## Method details

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

```php
public static function loadLockPackage(Composer\Package\Loader\ArrayLoader $loader, array $lockData, bool $dev = false): array
```

Load the packages in the packages section of the locker load data.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$loader` | `Composer\Package\Loader\ArrayLoader` | The package loader of composer. |
| `$lockData` | `array` | The lock data of locker. |
| `$dev` | `bool` | Check if the dev packages must be loaded. |

**Returns**

`array`: The lock data

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

```php
public static function loadLockPackages(array $lockData): array
```

Loads the `packages` and `packages-dev` entries of the lock data, leaving every other key unchanged.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$lockData` | `array` | The raw lock data, as read from the lock file. |

**Returns**

`array`: The lock data with package entries replaced by package instances.