ExistenceChecker

Class
Read only: Yes Final: Yes

Checks the existence of files and directories in a given base path.

Description

This class determines which candidate paths from the canonical list actually exist in the target repository, enabling selective export-ignore rules.

Table of Contents

Interfaces

ExistenceCheckerInterface

Checks the existence of files and directories in a given base path.

Properties

 : Filesystem

Methods

 : mixed
exists()

Checks if a path exists as a file or directory.

 : bool
filterExisting()

Filters a list of paths to only those that exist.

 : array<int, string>
isDirectory()

Checks if a path is a directory.

 : bool
isFile()

Checks if a path is a file.

 : bool
absolutePath()

Resolves a candidate path against the repository base path.

 : string
Properties

$filesystem

Private
private Filesystem $filesystem = new Filesystem()
Methods

__construct()

Public
public __construct([Filesystem  $filesystem = new Filesystem()]) : mixed
Parameters
$filesystem : Filesystem = new Filesystem()

exists()

Public

Checks if a path exists as a file or directory.

public exists( string  $basePath, string  $path) : bool
Parameters
$basePath : string

Description

the repository base path used to resolve the candidate

$path : string

Description

The path to check (e.g., "/.github/" or "/.editorconfig")

Return values
bool

Description

True if the path exists as a file or directory

filterExisting()

Public

Filters a list of paths to only those that exist.

public filterExisting( string  $basePath, array<int, string>  $paths) : array<int, string>
Parameters
$basePath : string

Description

the repository base path used to resolve the candidates

$paths : array<int, string>

Description

The paths to filter

Return values
array<int, string>

Description

Only the paths that exist

isDirectory()

Public

Checks if a path is a directory.

public isDirectory( string  $basePath, string  $path) : bool
Parameters
$basePath : string

Description

the repository base path used to resolve the candidate

$path : string

Description

The path to check (e.g., "/.github/")

Return values
bool

Description

True if the path exists and is a directory

isFile()

Public

Checks if a path is a file.

public isFile( string  $basePath, string  $path) : bool
Parameters
$basePath : string

Description

the repository base path used to resolve the candidate

$path : string

Description

The path to check (e.g., "/.editorconfig")

Return values
bool

Description

True if the path exists and is a file

absolutePath()

Private

Resolves a candidate path against the repository base path.

private absolutePath( string  $basePath, string  $path) : string
Parameters
$basePath : string

Description

the repository base path

$path : string

Description

the candidate path in canonical form

Return values
string

Description

the absolute path used for filesystem checks