class FileAccessibilityAndValidationCheck implements EnvironmentCheck (View source)

Checks for the accessibility and file type validation of one or more files or folders.

Examples: // Checks /assets/calculator_files has .json files and all files are valid json files. EnvironmentCheckSuite::register('check', 'FileAccessibilityAndValidationCheck("' . BASE_PATH . '/assets/calculator_files/*.json", "jsonValidate", '.FileAccessibilityAndValidationCheck::CHECK_ALL.')', 'Check a json file exist and are all valid json files' );

// Checks /assets/calculator_files/calculator.json exists and is valid json file. EnvironmentCheckSuite::register('check', 'FileAccessibilityAndValidationCheck("' . BASE_PATH . '/assets/calculator_files/calculator.json", "jsonValidate", '.FileAccessibilityAndValidationCheck::CHECK_SINGLE.')', 'Check a calculator.json exists and is valid json file' );

// Check only existence EnvironmentCheckSuite::register('check', 'FileAccessibilityAndValidationCheck("' . BASE_PATH . '/assets/calculator_files/calculator.json")', 'Check a calculator.json exists only' );

Constants

CHECK_SINGLE

CHECK_ALL

Properties

protected string $path

Absolute path to a file or folder, compatible with glob().

protected int $fileTypeValidateFunc

Constant, check for a single file to match age criteria, or all of them.

protected int $checkType

Constant, check for a single file to match age criteria, or all of them.

Methods

public
__construct(string $path, string $fileTypeValidateFunc = 'noVidation', null|int $checkType = null)

No description

public
array
check()

No description

protected
bool
noVidation(string $file)

No description

protected
array
getFiles()

Gets a list of absolute file paths.

Details

__construct(string $path, string $fileTypeValidateFunc = 'noVidation', null|int $checkType = null)

No description

Parameters

string $path
string $fileTypeValidateFunc
null|int $checkType

array check()

No description

Return Value

array

Result with 'status' and 'message' keys.

Status is EnvironmentCheck::ERROR, EnvironmentCheck::WARNING, or EnvironmentCheck::OK.

protected bool noVidation(string $file)

No description

Parameters

string $file

Return Value

bool

protected array getFiles()

Gets a list of absolute file paths.

Return Value

array