Represents a .gitignore file with its path and entries.
Description
This class implements IteratorAggregate to allow iteration over entries and provides a factory method to load .gitignore content from the file system.
Description
GitIgnoreInterface
Interfaces
Properties
Methods
Initializes a GitIgnore instance with the given path and entries.
Returns the list of entries from the .gitignore file.
Creates a GitIgnore instance from a file path.
Returns an iterator over the .gitignore entries.
Returns the file system path to the .gitignore file.
Initializes a GitIgnore instance with the given path and entries.
public
__construct(
string
$path,
array<int, string>
$entries) : mixed
Parameters
$path
:
string
Description
the file system path to the .gitignore file
$entries
:
array<int, string>
Description
the .gitignore entries
Returns the list of entries from the .gitignore file.
public
entries() : array<int, string>
Return values
Description
the non-empty .gitignore entries
Creates a GitIgnore instance from a file path.
public
static
fromFile(
string
$gitignorePath) : static
Description
If the file does not exist, returns an empty GitIgnore with the given path. Empty lines and whitespace-only lines are filtered from the entries.
Parameters
$gitignorePath
:
string
Description
the file system path to the .gitignore file
Return values
Description
a new GitIgnore instance
Returns an iterator over the .gitignore entries.
public
getIterator() : ArrayIterator<int, string>
Description
This method implements the IteratorAggregate interface.
Return values
Description
an iterator over the entries
Returns the file system path to the .gitignore file.
public
path() : string
Return values
Description
the absolute path to the .gitignore file