# ApplyPreview

> Represents the content a destination has now and the content it would have after applying its provider mapping.

[API reference](/docs/api/index.md) › [Scaffold](/docs/extensions/scaffold/reference/index.md) › [Services](/docs/extensions/scaffold/reference/services/index.md) › ApplyPreview

| final readonly class | `PHPForge\Scaffold\Services\ApplyPreview` |
| --- | --- |
| Source | [`src/Services/ApplyPreview.php`](https://github.com/php-forge/scaffold/blob/main/src/Services/ApplyPreview.php#L17) |

Represents the content a destination has now and the content it would have after applying its provider mapping.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-current"></span>`$current` readonly constructor | `string` | Destination content on disk; an empty string when the destination does not exist. | `ApplyPreview` |
| <span id="property-exists"></span>`$exists` readonly constructor | `bool` | Whether the destination exists on disk. | `ApplyPreview` |
| <span id="property-informational"></span>`$informational` readonly constructor | `bool` | Whether the destination is an existing `preserve` file that only `reapply --force` overwrites. Default: `false`. | `ApplyPreview` |
| <span id="property-mapping"></span>`$mapping` readonly constructor | [`PHPForge\Scaffold\Manifest\FileMapping`](/docs/extensions/scaffold/reference/manifest/filemapping/index.md) | Mapping that would be applied. | `ApplyPreview` |
| <span id="property-proposed"></span>`$proposed` readonly constructor | `string` | Destination content after applying the mapping. | `ApplyPreview` |
| <span id="property-userModified"></span>`$userModified` readonly constructor | `bool` | Whether the destination is a `replace` file that scaffold skips because it changed since the last apply or was adopted. Default: `false`. | `ApplyPreview` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a preview of applying a provider mapping. | `ApplyPreview` |
| [`changes()`](#method-changes) | Returns whether applying the mapping would create the destination or change its bytes. | `ApplyPreview` |
| [`differsOnlyInLineEndings()`](#method-differsOnlyInLineEndings) | Returns whether the current and proposed contents differ only in their line endings. | `ApplyPreview` |

## Method details

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

```php
public function __construct(PHPForge\Scaffold\Manifest\FileMapping $mapping, bool $exists, string $current, string $proposed, bool $userModified = false, bool $informational = false)
```

Creates a preview of applying a provider mapping.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$mapping` | [`PHPForge\Scaffold\Manifest\FileMapping`](/docs/extensions/scaffold/reference/manifest/filemapping/index.md) | Mapping that would be applied. |
| `$exists` | `bool` | Whether the destination exists on disk. |
| `$current` | `string` | Destination content on disk; an empty string when the destination does not exist. |
| `$proposed` | `string` | Destination content after applying the mapping. |
| `$userModified` | `bool` | Whether the destination is a `replace` file that scaffold skips because it changed since the last apply or was adopted. |
| `$informational` | `bool` | Whether the destination is an existing `preserve` file that only `reapply --force` overwrites. |

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

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

Returns whether applying the mapping would create the destination or change its bytes.

**Returns**

`bool`: `true` when the destination is missing or its content differs from the proposed one, `false` otherwise.

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

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

Returns whether the current and proposed contents differ only in their line endings.

**Returns**

`bool`: `true` when the destination exists and its content equals the proposed one after normalising line endings, `false` otherwise.