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

Methods

__construct()

Creates a writer with the filesystem dependency used for persistence.

 : mixed
render()

Renders the normalized .gitignore content.

 : string
write()

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

 : void
Properties
Methods

__construct()

Public

Creates a writer with the filesystem dependency used for persistence.

public __construct(FilesystemInterface  $filesystem) : mixed

Description

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

Parameters
$filesystem : FilesystemInterface

Description

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

render()

Public

Renders the normalized .gitignore content.

public render(GitIgnoreInterface  $gitignore) : string
Parameters
$gitignore : GitIgnoreInterface

Description

the gitignore representation to render

Return values
string

Description

the rendered file 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.