Skip to content
PHP Ecosystem
Explore

DiffColorizer

API reference › Scaffold › Console › DiffColorizer

final classPHPForge\Scaffold\Console\DiffColorizer
Sourcesrc/Console/DiffColorizer.php

Colors unified diff lines with raw ANSI escape codes: the first two lines (file headers) in bold, hunk headers in cyan, added lines in green and removed lines in red.

MethodDescriptionDefined by
colorize()Colors a unified diff whose first two lines are the --- and +++ file headers.DiffColorizer
public function colorize(string $diff): string

Colors a unified diff whose first two lines are the --- and +++ file headers.

Parameters

ParameterTypeDescription
$diffstringUnified diff with "\n" line separators.

Returns

string: Diff with each styled line wrapped in ANSI escape codes; context lines stay unstyled.