Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Fast Forward Development Tools for PHP projects.
7 *
8 * This file is part of fast-forward/dev-tools project.
9 *
10 * @author   Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
11 * @license  https://opensource.org/licenses/MIT MIT License
12 *
13 * @see      https://github.com/php-fast-forward/
14 * @see      https://github.com/php-fast-forward/dev-tools
15 * @see      https://github.com/php-fast-forward/dev-tools/issues
16 * @see      https://php-fast-forward.github.io/dev-tools/
17 * @see      https://datatracker.ietf.org/doc/html/rfc2119
18 */
19
20namespace FastForward\DevTools\GitIgnore;
21
22/**
23 * Defines the contract for classifying .gitignore entries.
24 *
25 * This classifier SHALL inspect a raw .gitignore entry and determine whether the
26 * entry expresses directory semantics or file semantics. Implementations MUST
27 * preserve deterministic classification for identical inputs. Blank entries and
28 * comment entries MUST be treated as file-oriented values to avoid incorrectly
29 * inferring directory intent where no effective pattern exists.
30 */
31interface ClassifierInterface
32{
33    /**
34     * Classifies a .gitignore entry as directory or file pattern.
35     *
36     * @param string $entry the .gitignore entry to classify
37     *
38     * @return 'directory'|'file' the classification result
39     */
40    public function classify(string $entry): string;
41
42    /**
43     * Determines whether the entry represents a directory pattern.
44     *
45     * @param string $entry the .gitignore entry to check
46     *
47     * @return bool true if the entry is a directory pattern
48     */
49    public function isDirectory(string $entry): bool;
50
51    /**
52     * Determines whether the entry represents a file pattern.
53     *
54     * @param string $entry the .gitignore entry to check
55     *
56     * @return bool true if the entry is a file pattern
57     */
58    public function isFile(string $entry): bool;
59}