class FileAgeCheck implements EnvironmentCheck (View source)

Checks for the maximum age of one or more files or folders.

Useful for files which should be frequently auto-generated, like static caches, as well as for backup files and folders. Does NOT check for existence of a file (will silently fail).

Examples: // Checks that Requirements::combine_files() has regenerated files in the last 24h EnvironmentCheckSuite::register( 'check', 'FileAgeCheck("' . ASSETS_PATH . '/_combined_files/*.js' . '", "-1 day", '>', " . FileAgeCheck::CHECK_ALL) . "' );

// Checks that at least one backup folder has been created in the last 24h EnvironmentCheckSuite::register( 'check', 'FileAgeCheck("' . BASE_PATH . '/../backups/*' . '", "-1 day", '>', " . FileAgeCheck::CHECK_SINGLE) . "' );

Constants

CHECK_SINGLE

CHECK_ALL

Properties

protected string $path

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

protected string $relativeAge

Relative date specification, compatible with strtotime().

protected string $checkFn

The function to use for checking file age: so filemtime(), filectime(), or fileatime().

protected int $checkType

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

protected string $compareOperand

Type of comparison (either > or <).

Methods

public
__construct(string $path, string $relativeAge, string $compareOperand = '>', null|int $checkType = null, string $checkFn = 'filemtime')

No description

public
array
check()

No description

protected
array
getFiles()

Gets a list of absolute file paths.

Details

__construct(string $path, string $relativeAge, string $compareOperand = '>', null|int $checkType = null, string $checkFn = 'filemtime')

No description

Parameters

string $path
string $relativeAge
string $compareOperand
null|int $checkType
string $checkFn

array check()

No description

Return Value

array

Result with 'status' and 'message' keys.

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

protected array getFiles()

Gets a list of absolute file paths.

Return Value

array