11<?php
22
3+ declare (strict_types=1 );
4+
35/**
46 * SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
57 * SPDX-License-Identifier: AGPL-3.0-or-later
68 */
79namespace OCP ;
810
911/**
10- * Class HintException
11- *
1212 * An Exception class with the intention to be presented to the end user
1313 *
14- * @package OCP
1514 * @since 23.0.0
1615 */
1716class HintException extends \Exception {
18- private $ hint ;
19-
2017 /**
2118 * HintException constructor.
2219 *
2320 * @since 23.0.0
24- * @param string $message The error message. It will be not revealed to the
25- * the user (unless the hint is empty) and thus
26- * should be not translated.
27- * @param string $hint A useful message that is presented to the end
28- * user. It should be translated, but must not
29- * contain sensitive data.
21+ * @param string $message The error message. It is not intended to be shown
22+ * to the end user unless the hint is empty, and
23+ * therefore should not be translated.
24+ * @param string $hint A useful message presented to the end user. It should
25+ * be translated, but must not contain sensitive data.
3026 * @param int $code
3127 * @param \Exception|null $previous
3228 */
33- public function __construct ($ message , $ hint = '' , $ code = 0 , ?\Exception $ previous = null ) {
34- $ this ->hint = $ hint ;
29+ public function __construct (
30+ string $ message ,
31+ private string $ hint = '' ,
32+ int $ code = 0 ,
33+ ?\Exception $ previous = null ,
34+ ) {
3535 parent ::__construct ($ message , $ code , $ previous );
3636 }
3737
@@ -40,7 +40,6 @@ public function __construct($message, $hint = '', $code = 0, ?\Exception $previo
4040 * code, the message and the hint.
4141 *
4242 * @since 23.0.0
43- * @return string
4443 */
4544 public function __toString (): string {
4645 return self ::class . ": [ {$ this ->code }]: {$ this ->message } ( {$ this ->hint }) \n" ;
@@ -52,12 +51,8 @@ public function __toString(): string {
5251 * instead.
5352 *
5453 * @since 23.0.0
55- * @return string
5654 */
5755 public function getHint (): string {
58- if (empty ($ this ->hint )) {
59- return $ this ->message ;
60- }
61- return $ this ->hint ;
56+ return $ this ->hint !== '' ? $ this ->hint : $ this ->message ;
6257 }
6358}
0 commit comments