# ResolvedPackage

> Represents a package chosen for installation: a registry tarball or a local file: directory.

[API reference](/docs/api/index.md) › [Foxy](/docs/extensions/foxy/reference/index.md) › [Native](/docs/extensions/foxy/reference/native/index.md) › ResolvedPackage

| final readonly class | `Foxy\Native\ResolvedPackage` |
| --- | --- |
| Source | [`src/Native/ResolvedPackage.php`](https://github.com/php-forge/foxy/blob/main/src/Native/ResolvedPackage.php#L10) |

Represents a package chosen for installation: a registry tarball or a local `file:` directory.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-integrity"></span>`$integrity` readonly constructor | `string\|null` | Subresource Integrity value of a registry package. Default: `null`. | `ResolvedPackage` |
| <span id="property-name"></span>`$name` readonly constructor | `string` | Package name. | `ResolvedPackage` |
| <span id="property-path"></span>`$path` readonly constructor | `string\|null` | Local package directory: the manifest's `file:` value without the prefix, as written. Default: `null`. | `ResolvedPackage` |
| <span id="property-resolved"></span>`$resolved` readonly constructor | `string\|null` | Tarball URL of a registry package. Default: `null`. | `ResolvedPackage` |
| <span id="property-version"></span>`$version` readonly constructor | `string` | Installed version. | `ResolvedPackage` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Describes a registry or local package selected for installation. | `ResolvedPackage` |
| [`fromLocal()`](#method-fromLocal) static | Creates a local package from a `file:` dependency. | `ResolvedPackage` |
| [`fromRegistry()`](#method-fromRegistry) static | Creates a registry package from the selected version's tarball URL and integrity value. | `ResolvedPackage` |
| [`isLocal()`](#method-isLocal) | Returns whether the package is copied from a local directory instead of downloaded from the registry. | `ResolvedPackage` |
| [`toLock()`](#method-toLock) | Returns the package entry written to `foxy.lock`. | `ResolvedPackage` |

## Method details

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

```php
public function __construct(string $name, string $version, string|null $resolved = null, string|null $integrity = null, string|null $path = null)
```

Describes a registry or local package selected for installation.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` | Package name. |
| `$version` | `string` | Installed version. |
| `$resolved` | `string\|null` | Tarball URL of a registry package. |
| `$integrity` | `string\|null` | Subresource Integrity value of a registry package. |
| `$path` | `string\|null` | Local package directory: the manifest's `file:` value without the prefix, as written. |

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

```php
public static function fromLocal(string $name, string $version, string $path): self
```

Creates a local package from a `file:` dependency.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` |  |
| `$version` | `string` |  |
| `$path` | `string` |  |

**Returns**

`self`

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

```php
public static function fromRegistry(Foxy\Native\PackageVersion $version): self
```

Creates a registry package from the selected version's tarball URL and integrity value.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$version` | [`PackageVersion`](/docs/extensions/foxy/reference/native/packageversion/index.md) |  |

**Returns**

`self`

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

```php
public function isLocal(): bool
```

Returns whether the package is copied from a local directory instead of downloaded from the registry.

**Returns**

`bool`

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

```php
public function toLock(): array{version: string, file: string}|array{version: string, resolved: string, integrity: string}
```

Returns the package entry written to `foxy.lock`.

**Returns**

`array{version: string, file: string}|array{version: string, resolved: string, integrity: string}`