summaryrefslogtreecommitdiffstats
path: root/lib/public/SetupCheck/SetupResult.php
blob: 59d04323cd4bada1b3e26acbce5d2daca5e777ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php

namespace OCP\SetupCheck;

/**
 * @brief This class is used for storing the result of a setup check
 *
 * @since 28.0.0
 */
class SetupResult implements \JsonSerializable {
	public const SUCCESS = 'success';
	public const INFO = 'info';
	public const WARNING = 'warning';
	public const ERROR = 'error';

	/**
	 * @param self::SUCCESS|self::INFO|self::WARNING|self::ERROR $severity
	 * @since 28.0.0
	 */
	public function __construct(
		private string $severity,
		private ?string $description = null,
		private ?string $linkToDoc = null,
	) {
	}

	/**
	 * @brief Get the severity for the setup check result
	 *
	 * @return self::SUCCESS|self::INFO|self::WARNING|self::ERROR
	 * @since 28.0.0
	 */
	public function getSeverity(): string {
		return $this->severity;
	}

	/**
	 * @brief Get the description for the setup check result
	 *
	 * @since 28.0.0
	 */
	public function getDescription(): ?string {
		return $this->description;
	}

	/**
	 * @brief Get a link to the doc for the explanation.
	 *
	 * @since 28.0.0
	 */
	public function getLinkToDoc(): ?string {
		return $this->linkToDoc;
	}

	/**
	 * @brief Get an array representation of the result for API responses
	 *
	 * @since 28.0.0
	 */
	public function jsonSerialize(): array {
		return [
			'severity' => $this->severity,
			'description' => $this->description,
			'linkToDoc' => $this->linkToDoc,
		];
	}
}