aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-10-16 17:23:47 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-10-19 11:44:03 +0200
commit2e4d1549a44ce3b29d3287ba3721a464733bf708 (patch)
treeb7ab204e34f2920ebd0f339bc53f292a5f797158 /lib
parent11ebf469da14224b3e1146b65eb16095ab8b22a8 (diff)
downloadnextcloud-server-2e4d1549a44ce3b29d3287ba3721a464733bf708.tar.gz
nextcloud-server-2e4d1549a44ce3b29d3287ba3721a464733bf708.zip
Change SetupResult API to named constructors
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/public/SetupCheck/SetupResult.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/public/SetupCheck/SetupResult.php b/lib/public/SetupCheck/SetupResult.php
index 158a9489cfe..27026f82815 100644
--- a/lib/public/SetupCheck/SetupResult.php
+++ b/lib/public/SetupCheck/SetupResult.php
@@ -38,10 +38,11 @@ class SetupResult implements \JsonSerializable {
public const ERROR = 'error';
/**
+ * @brief Private constructor, use success()/info()/warning()/error() instead
* @param self::SUCCESS|self::INFO|self::WARNING|self::ERROR $severity
* @since 28.0.0
*/
- public function __construct(
+ private function __construct(
private string $severity,
private ?string $description = null,
private ?string $linkToDoc = null,
@@ -49,6 +50,38 @@ class SetupResult implements \JsonSerializable {
}
/**
+ * @brief Create a success result object
+ * @since 28.0.0
+ */
+ public static function success(?string $description = null, ?string $linkToDoc = null): self {
+ return new self(self::SUCCESS, $description, $linkToDoc);
+ }
+
+ /**
+ * @brief Create an info result object
+ * @since 28.0.0
+ */
+ public static function info(?string $description = null, ?string $linkToDoc = null): self {
+ return new self(self::INFO, $description, $linkToDoc);
+ }
+
+ /**
+ * @brief Create a warning result object
+ * @since 28.0.0
+ */
+ public static function warning(?string $description = null, ?string $linkToDoc = null): self {
+ return new self(self::WARNING, $description, $linkToDoc);
+ }
+
+ /**
+ * @brief Create an error result object
+ * @since 28.0.0
+ */
+ public static function error(?string $description = null, ?string $linkToDoc = null): self {
+ return new self(self::ERROR, $description, $linkToDoc);
+ }
+
+ /**
* @brief Get the severity for the setup check result
*
* @return self::SUCCESS|self::INFO|self::WARNING|self::ERROR