-
-
Notifications
You must be signed in to change notification settings - Fork 0
Classifier
Classifies .gitignore entries as directory-oriented or file-oriented patterns.
This classifier SHALL inspect a raw .gitignore entry and determine whether the entry expresses directory semantics or file semantics. Implementations MUST preserve deterministic classification for identical inputs. Blank entries and comment entries MUST be treated as file-oriented values to avoid incorrectly inferring directory intent where no effective pattern exists.
- Full name:
\FastForward\DevTools\GitIgnore\Classifier - This class is marked as final and can't be subclassed
- This class implements:
\FastForward\DevTools\GitIgnore\ClassifierInterface - This class is a Final class
Classifies a .gitignore entry as either a directory or a file pattern.
public classify(string $entry): stringThe provided entry SHALL be normalized with trim() before any rule is evaluated. Empty entries and comment entries MUST be classified as files. Entries ending with "/" MUST be classified as directories. Patterns that indicate directory traversal or wildcard directory matching SHOULD also be classified as directories.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$entry |
string | The raw .gitignore entry to classify. |
Return Value:
The classification result. The value MUST be either self::DIRECTORY or self::FILE.
Determines whether the given .gitignore entry represents a directory pattern.
public isDirectory(string $entry): boolThis method MUST delegate the effective classification to classify() and SHALL return true only when the resulting classification is self::DIRECTORY.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$entry |
string | The raw .gitignore entry to evaluate. |
Return Value:
true when the entry is classified as a directory pattern; otherwise, false
Determines whether the given .gitignore entry represents a file pattern.
public isFile(string $entry): boolThis method MUST delegate the effective classification to classify() and SHALL return true only when the resulting classification is self::FILE.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$entry |
string | The raw .gitignore entry to evaluate. |
Return Value:
true when the entry is classified as a file pattern; otherwise, false