ApplyPreview
API reference › Scaffold › Services › ApplyPreview
Represents the content a destination has now and the content it would have after applying its provider mapping.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$current readonly constructor | string | Destination content on disk; an empty string when the destination does not exist. | ApplyPreview |
$exists readonly constructor | bool | Whether the destination exists on disk. | ApplyPreview |
$informational readonly constructor | bool | Whether the destination is an existing preserve file that only reapply --force overwrites. Default: false. | ApplyPreview |
$mapping readonly constructor | PHPForge\ | Mapping that would be applied. | ApplyPreview |
$proposed readonly constructor | string | Destination content after applying the mapping. | ApplyPreview |
$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
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates a preview of applying a provider mapping. | ApplyPreview |
changes() | Returns whether applying the mapping would create the destination or change its bytes. | ApplyPreview |
differsOnlyInLineEndings() | Returns whether the current and proposed contents differ only in their line endings. | ApplyPreview |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”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\ | 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()
Section titled “changes() ”public function changes(): boolReturns 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()
Section titled “differsOnlyInLineEndings() ”public function differsOnlyInLineEndings(): boolReturns 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.