Writer

Class
implements WriterInterface
Read only: Yes Final: Yes

Persists normalized .gitattributes content.

Description

This writer SHALL align attribute declarations using the longest path spec, write the provided textual content to the target path, and MUST append a final trailing line feed for deterministic formatting.

Table of Contents

Interfaces

WriterInterface

Defines the contract for writing .gitattributes files to persistent storage.

Properties

Methods

 : mixed
render()

Renders normalized .gitattributes content.

 : string
write()

Writes the .gitattributes content to the specified filesystem path.

 : void
firstUnescapedWhitespacePosition()

Locates the first non-escaped whitespace separator in a line.

 : int|null
format()

Formats .gitattributes content with aligned attribute columns.

 : string
parseEntry()

Parses a .gitattributes entry into its path spec and attribute segment.

 : array{path_spec: string, attributes: string}|null
Properties
Methods

render()

Public

Renders normalized .gitattributes content.

public render( string  $content) : string
Parameters
$content : string

Description

the merged .gitattributes content to normalize

Return values
string

Description

the normalized file content

write()

Public

Writes the .gitattributes content to the specified filesystem path.

public write( string  $gitattributesPath, string  $content) : void
Parameters
$gitattributesPath : string

Description

The filesystem path to the .gitattributes file.

$content : string

Description

The merged .gitattributes content to persist.

firstUnescapedWhitespacePosition()

Private

Locates the first non-escaped whitespace separator in a line.

private firstUnescapedWhitespacePosition( string  $line) : int|null
Parameters
$line : string

Description

the line to inspect

Return values
int|null

format()

Private

Formats .gitattributes content with aligned attribute columns.

private format( string  $content) : string
Parameters
$content : string

Description

The merged .gitattributes content to normalize.

Return values
string

parseEntry()

Private

Parses a .gitattributes entry into its path spec and attribute segment.

private parseEntry( string  $line) : array{path_spec: string, attributes: string}|null
Parameters
$line : string

Description

The normalized .gitattributes line.

Return values
array{path_spec: string, attributes: string}|null