From 0908db80168f427cfb6716092d6ffae81995c702 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 5 Jun 2024 17:00:30 +1200 Subject: [PATCH] ENH Use class name instead of self --- src/Checks/FileAccessibilityAndValidationCheck.php | 6 ++++-- src/Checks/FileAgeCheck.php | 6 +++--- src/EnvironmentCheckSuite.php | 13 +++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Checks/FileAccessibilityAndValidationCheck.php b/src/Checks/FileAccessibilityAndValidationCheck.php index abff14b..6bae00c 100644 --- a/src/Checks/FileAccessibilityAndValidationCheck.php +++ b/src/Checks/FileAccessibilityAndValidationCheck.php @@ -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; } /** @@ -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; diff --git a/src/Checks/FileAgeCheck.php b/src/Checks/FileAgeCheck.php index ff7dea3..5cc8050 100644 --- a/src/Checks/FileAgeCheck.php +++ b/src/Checks/FileAgeCheck.php @@ -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; } @@ -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( @@ -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) { diff --git a/src/EnvironmentCheckSuite.php b/src/EnvironmentCheckSuite.php index 3950126..c17f901 100644 --- a/src/EnvironmentCheckSuite.php +++ b/src/EnvironmentCheckSuite.php @@ -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; } @@ -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]; } /** @@ -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); } } @@ -210,6 +211,6 @@ public static function register($names, $check, $title = null) */ public static function reset() { - self::$instances = []; + EnvironmentCheckSuite::$instances = []; } }