Skip to content

Commit

Permalink
Merge branch '3' into 4
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jun 19, 2024
2 parents 7bd60f8 + 913390e commit cfefa51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/Checks/FileAccessibilityAndValidationCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __construct($path, $fileTypeValidateFunc = 'noVidation', $checkT
{
$this->path = $path;
$this->fileTypeValidateFunc = ($fileTypeValidateFunc)? $fileTypeValidateFunc : 'noVidation';
$this->checkType = ($checkType) ? $checkType : self::CHECK_SINGLE;
$this->checkType = ($checkType) ? $checkType : FileAccessibilityAndValidationCheck::CHECK_SINGLE;
}

/**
Expand Down Expand Up @@ -109,7 +109,9 @@ public function check()
}

// If at least one file was valid, count as passed
if ($this->checkType == self::CHECK_SINGLE && count($invalidFiles ?? []) < count($files ?? [])) {
if ($this->checkType == FileAccessibilityAndValidationCheck::CHECK_SINGLE
&& count($invalidFiles ?? []) < count($files ?? [])
) {
$validFileList = PHP_EOL;
foreach ($validFiles as $vf) {
$validFileList .= $vf . PHP_EOL;
Expand Down
6 changes: 3 additions & 3 deletions src/Checks/FileAgeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function __construct($path, $relativeAge, $compareOperand = '>', $checkTy
$this->path = $path;
$this->relativeAge = $relativeAge;
$this->checkFn = $checkFn;
$this->checkType = ($checkType) ? $checkType : self::CHECK_SINGLE;
$this->checkType = ($checkType) ? $checkType : FileAgeCheck::CHECK_SINGLE;
$this->compareOperand = $compareOperand;
}

Expand All @@ -110,7 +110,7 @@ public function check()
$validFiles[] = $file;
} else {
$invalidFiles[] = $file;
if ($this->checkType == self::CHECK_ALL) {
if ($this->checkType == FileAgeCheck::CHECK_ALL) {
return [
EnvironmentCheck::ERROR,
sprintf(
Expand All @@ -127,7 +127,7 @@ public function check()
}

// If at least one file was valid, count as passed
if ($this->checkType == self::CHECK_SINGLE && count($invalidFiles ?? []) < count($files ?? [])) {
if ($this->checkType == FileAgeCheck::CHECK_SINGLE && count($invalidFiles ?? []) < count($files ?? [])) {
return [EnvironmentCheck::OK, ''];
}
if (count($invalidFiles ?? []) == 0) {
Expand Down
13 changes: 7 additions & 6 deletions src/EnvironmentCheckSuite.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class EnvironmentCheckSuite
public function __construct($suiteName)
{
if (empty($this->config()->registered_suites[$suiteName])) {
// Not registered via config system, but it still may be configured later via self::register.
// Not registered via config system, but it still may be configured later
// via EnvironmentCheckSuite::register.
return;
}

Expand Down Expand Up @@ -181,10 +182,10 @@ public function push($check, $title = null)
*/
public static function inst($name)
{
if (!isset(self::$instances[$name])) {
self::$instances[$name] = new EnvironmentCheckSuite($name);
if (!isset(EnvironmentCheckSuite::$instances[$name])) {
EnvironmentCheckSuite::$instances[$name] = new EnvironmentCheckSuite($name);
}
return self::$instances[$name];
return EnvironmentCheckSuite::$instances[$name];
}

/**
Expand All @@ -201,7 +202,7 @@ public static function register($names, $check, $title = null)
}

foreach ($names as $name) {
self::inst($name)->push($check, $title);
EnvironmentCheckSuite::inst($name)->push($check, $title);
}
}

Expand All @@ -210,6 +211,6 @@ public static function register($names, $check, $title = null)
*/
public static function reset()
{
self::$instances = [];
EnvironmentCheckSuite::$instances = [];
}
}

0 comments on commit cfefa51

Please sign in to comment.