Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Use class name instead of self #104

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = [];
}
}
Loading