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\GitAttributes;
21
22/**
23 * Checks the existence of files and directories in a given base path.
24 *
25 * This interface defines the contract for determining which candidate
26 * paths actually exist in the target repository.
27 */
28interface ExistenceCheckerInterface
29{
30    /**
31     * Checks if a path exists as a file or directory.
32     *
33     * @param string $basePath the repository base path used to resolve the candidate
34     * @param string $path The path to check (e.g., "/.github/" or "/.editorconfig")
35     *
36     * @return bool True if the path exists as a file or directory
37     */
38    public function exists(string $basePath, string $path): bool;
39
40    /**
41     * Filters a list of paths to only those that exist.
42     *
43     * @param string $basePath the repository base path used to resolve the candidates
44     * @param list<string> $paths The paths to filter
45     *
46     * @return list<string> Only the paths that exist
47     */
48    public function filterExisting(string $basePath, array $paths): array;
49
50    /**
51     * Checks if a path is a directory.
52     *
53     * @param string $basePath the repository base path used to resolve the candidate
54     * @param string $path The path to check (e.g., "/.github/")
55     *
56     * @return bool True if the path exists and is a directory
57     */
58    public function isDirectory(string $basePath, string $path): bool;
59
60    /**
61     * Checks if a path is a file.
62     *
63     * @param string $basePath the repository base path used to resolve the candidate
64     * @param string $path The path to check (e.g., "/.editorconfig")
65     *
66     * @return bool True if the path exists and is a file
67     */
68    public function isFile(string $basePath, string $path): bool;
69}