Skip to content
PHP Ecosystem
Explore

ApplyPreview

API reference › Scaffold › Services › ApplyPreview

final readonly classPHPForge\Scaffold\Services\ApplyPreview
Sourcesrc/Services/ApplyPreview.php

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

PropertyTypeDescriptionDefined by
$current readonly constructorstringDestination content on disk; an empty string when the destination does not exist.ApplyPreview
$exists readonly constructorboolWhether the destination exists on disk.ApplyPreview
$informational readonly constructorboolWhether the destination is an existing preserve file that only reapply --force overwrites. Default: false.ApplyPreview
$mapping readonly constructorPHPForge\Scaffold\Manifest\FileMappingMapping that would be applied.ApplyPreview
$proposed readonly constructorstringDestination content after applying the mapping.ApplyPreview
$userModified readonly constructorboolWhether the destination is a replace file that scaffold skips because it changed since the last apply or was adopted. Default: false.ApplyPreview
MethodDescriptionDefined 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
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

ParameterTypeDescription
$mappingPHPForge\Scaffold\Manifest\FileMappingMapping that would be applied.
$existsboolWhether the destination exists on disk.
$currentstringDestination content on disk; an empty string when the destination does not exist.
$proposedstringDestination content after applying the mapping.
$userModifiedboolWhether the destination is a replace file that scaffold skips because it changed since the last apply or was adopted.
$informationalboolWhether the destination is an existing preserve file that only reapply --force overwrites.
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.

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.