Skip to content
PHP Ecosystem
Explore

ApplyPreviewer

API reference › Scaffold › Services › ApplyPreviewer

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

Computes in memory what applying a provider mapping would write to its destination, without touching the disk.

MethodDescriptionDefined by
preview()Returns the current and proposed content of the mapping destination: the stub for replace and preserve, the merge result for append, and the prepended block for prepend.ApplyPreviewer
public function preview(PHPForge\Scaffold\Manifest\FileMapping $mapping, string $projectRoot, PHPForge\Scaffold\Services\LockEntry|null $entry = null): PHPForge\Scaffold\Services\ApplyPreview

Returns the current and proposed content of the mapping destination: the stub for replace and preserve, the merge result for append, and the prepended block for prepend.

Parameters

ParameterTypeDescription
$mappingPHPForge\Scaffold\Manifest\FileMappingValidated mapping to preview.
$projectRootstringAbsolute path to the project root.
$entryPHPForge\Scaffold\Services\LockEntry|nullLock entry of the destination, or null when it is untracked.

Returns

ApplyPreview: Current and proposed content of the destination, with its replace and preserve flags.

Throws

  • RuntimeException: when the stub is missing or a file cannot be read or hashed.