Writer

Class
implements WriterInterface
Read only: Yes Final: Yes

Renders and persists normalized .gitignore content.

Description

This writer SHALL transform a GitIgnoreInterface representation into the textual format expected by a .gitignore file and MUST persist that content to the target path exposed by the provided object. Implementations MUST write a trailing line feed to ensure consistent file formatting.

Table of Contents

Interfaces

WriterInterface

Defines the contract for writing .gitignore representations to persistent storage.

Properties

 : Filesystem

Methods

__construct()

Creates a writer with the filesystem dependency used for persistence.

 : mixed
write()

Writes the normalized .gitignore entries to the target file path.

 : void
Properties

$filesystem

Private
private Filesystem $filesystem
Methods

__construct()

Public

Creates a writer with the filesystem dependency used for persistence.

public __construct(Filesystem  $filesystem) : mixed

Description

The provided filesystem implementation MUST support writing file contents to the target path returned by a GitIgnoreInterface instance.

Parameters
$filesystem : Filesystem

Description

The filesystem service responsible for writing the rendered .gitignore content.

write()

Public

Writes the normalized .gitignore entries to the target file path.

public write(GitIgnoreInterface  $gitignore) : void

Description

The implementation SHALL join all entries using a Unix line feed and MUST append a final trailing line feed to the generated content. The resulting content MUST be written to the path returned by $gitignore->path().

Parameters
$gitignore : GitIgnoreInterface

Description

The .gitignore representation whose path and entries SHALL be written.