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.
Interfaces
Defines the contract for writing .gitattributes files to persistent storage.
Properties
Methods
Renders normalized .gitattributes content.
Writes the .gitattributes content to the specified filesystem path.
Locates the first non-escaped whitespace separator in a line.
Formats .gitattributes content with aligned attribute columns.
Parses a .gitattributes entry into its path spec and attribute segment.
private
FilesystemInterface
$filesystem
public
__construct(FilesystemInterface
$filesystem) : mixed
Parameters
Description
the filesystem service responsible for writing the file
Renders normalized .gitattributes content.
public
render(
string
$content) : string
Parameters
$content
:
string
Description
the merged .gitattributes content to normalize
Return values
Description
the normalized file content
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.
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
Formats .gitattributes content with aligned attribute columns.
private
format(
string
$content) : string
Parameters
$content
:
string
Description
The merged .gitattributes content to normalize.
Return values
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.