Merges, deduplicates, and sorts .gitignore entries.
Description
This service SHALL combine canonical and project-specific .gitignore definitions into a single normalized result. The resulting entry list MUST exclude blank lines and comment lines from the merged output, MUST remove duplicate entries, and MUST group directory entries before file entries. Directory and file groups SHALL be sorted independently in ascending string order to provide deterministic output.
Interfaces
Properties
Methods
Initializes the merger with a classifier implementation.
Merges canonical and project .gitignore entries into a normalized result.
private
ClassifierInterface
$classifier
=
new Classifier()
Initializes the merger with a classifier implementation.
public
__construct([ClassifierInterface
$classifier = new Classifier()]) : mixed
Description
The classifier MUST be capable of determining whether a normalized .gitignore entry represents a directory or a file pattern. When no classifier is provided, a default Classifier instance SHALL be used.
Parameters
Description
the classifier responsible for distinguishing directory entries from file entries during merging
Merges canonical and project .gitignore entries into a normalized result.
public
merge(GitIgnoreInterface
$canonical, GitIgnoreInterface
$project) : GitIgnoreInterface
Description
The implementation MUST combine entries from both sources, MUST remove duplicates, and MUST ignore blank or commented entries after trimming. Entries identified as directories SHALL be collected separately from file entries. Each group MUST be sorted using string comparison, and directory entries MUST appear before file entries in the final result.
The returned GitIgnore instance SHALL preserve the project path provided by the $project argument.
Parameters
Description
The canonical .gitignore source whose entries provide the shared baseline.
Description
The project-specific .gitignore source whose path MUST be preserved in the merged result.
Return values
Description
A new merged .gitignore representation containing normalized, deduplicated, and ordered entries.