# DiffColorizer

> 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.

[API reference](/docs/api/index.md) › [Scaffold](/docs/extensions/scaffold/reference/index.md) › [Console](/docs/extensions/scaffold/reference/console/index.md) › DiffColorizer

| final class | `PHPForge\Scaffold\Console\DiffColorizer` |
| --- | --- |
| Source | [`src/Console/DiffColorizer.php`](https://github.com/php-forge/scaffold/blob/main/src/Console/DiffColorizer.php#L15) |

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.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`colorize()`](#method-colorize) | Colors a unified diff whose first two lines are the `---` and `+++` file headers. | `DiffColorizer` |

## Method details

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

```php
public function colorize(string $diff): string
```

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

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$diff` | `string` | Unified diff with `"\n"` line separators. |

**Returns**

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