‪TYPO3CMS  ‪main
Status.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
16 namespace ‪TYPO3\CMS\Reports;
17 
19 
23 class ‪Status
24 {
28  public const ‪NOTICE = -2;
32  public const ‪INFO = -1;
36  public const ‪OK = 0;
40  public const ‪WARNING = 1;
44  public const ‪ERROR = 2;
45 
49  protected ‪$title;
50 
54  protected ‪$value;
55 
59  protected ‪$message;
60 
62 
77  public function ‪__construct(‪$title, ‪$value, ‪$message = '', int|‪ContextualFeedbackSeverity ‪$severity = ContextualFeedbackSeverity::OK)
78  {
79  $this->title = (string)‪$title;
80  $this->value = (string)‪$value;
81  $this->message = (string)‪$message;
82  if (is_int(‪$severity)) {
83  // @deprecated int type for $severity deprecated in v12, will change to Severity only in v13.
84  ‪$severity = ContextualFeedbackSeverity::transform(‪$severity) ?? ContextualFeedbackSeverity::OK;
85  }
86  $this->severity = ‪$severity;
87  }
88 
94  public function ‪getTitle()
95  {
96  return ‪$this->title;
97  }
98 
104  public function ‪getValue()
105  {
106  return ‪$this->value;
107  }
108 
114  public function ‪getMessage()
115  {
117  }
118 
120  {
121  return ‪$this->severity;
122  }
123 
129  public function ‪__toString()
130  {
131  // Max length 80 characters
132  $stringRepresentation = str_pad('[' . $this->severity->name . ']', 7) . str_pad($this->title, 40) . ' - ' . substr($this->value, 0, 30);
133  return $stringRepresentation;
134  }
135 }
‪TYPO3\CMS\Reports\Status\NOTICE
‪const NOTICE
Definition: Status.php:28
‪TYPO3\CMS\Reports\Status\ERROR
‪const ERROR
Definition: Status.php:44
‪TYPO3\CMS\Reports\Status\getSeverity
‪getSeverity()
Definition: Status.php:116
‪TYPO3\CMS\Reports\Status\$severity
‪ContextualFeedbackSeverity $severity
Definition: Status.php:58
‪TYPO3\CMS\Reports\Status\getMessage
‪string getMessage()
Definition: Status.php:111
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Reports\Status\OK
‪const OK
Definition: Status.php:36
‪TYPO3\CMS\Reports\Status
Definition: Status.php:24
‪TYPO3\CMS\Reports\Status\__construct
‪__construct($title, $value, $message='', int|ContextualFeedbackSeverity $severity=ContextualFeedbackSeverity::OK)
Definition: Status.php:74
‪TYPO3\CMS\Reports\Status\WARNING
‪const WARNING
Definition: Status.php:40
‪TYPO3\CMS\Reports
‪TYPO3\CMS\Reports\Status\__toString
‪string __toString()
Definition: Status.php:126
‪TYPO3\CMS\Reports\Status\INFO
‪const INFO
Definition: Status.php:32
‪TYPO3\CMS\Reports\Status\getValue
‪string getValue()
Definition: Status.php:101
‪TYPO3\CMS\Reports\Status\$title
‪string $title
Definition: Status.php:48
‪TYPO3\CMS\Reports\Status\$value
‪string $value
Definition: Status.php:52
‪TYPO3\CMS\Reports\Status\getTitle
‪string getTitle()
Definition: Status.php:91
‪TYPO3\CMS\Reports\Status\$message
‪string $message
Definition: Status.php:56