TYPO3 CMS  TYPO3_8-7
Status.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Reports;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
17 
21 class Status
22 {
23  const NOTICE = -2;
24  const INFO = -1;
25  const OK = 0;
26  const WARNING = 1;
27  const ERROR = 2;
28 
32  protected $title;
33 
37  protected $value;
38 
42  protected $message;
43 
47  protected $severity;
48 
61  public function __construct($title, $value, $message = '', $severity = self::OK)
62  {
63  $this->title = (string)$title;
64  $this->value = (string)$value;
65  $this->message = (string)$message;
66  $this->severity = MathUtility::forceIntegerInRange($severity, self::NOTICE, self::ERROR, self::OK);
67  }
68 
74  public function getTitle()
75  {
76  return $this->title;
77  }
78 
84  public function getValue()
85  {
86  return $this->value;
87  }
88 
94  public function getMessage()
95  {
96  return $this->message;
97  }
98 
104  public function getSeverity()
105  {
106  return $this->severity;
107  }
108 
114  public function __toString()
115  {
116  $severity = [
117  self::NOTICE => 'NOTE',
118  self::INFO => 'INFO',
119  self::OK => 'OK',
120  self::WARNING => 'WARN',
121  self::ERROR => 'ERR'
122  ];
123  // Max length 80 characters
124  $stringRepresentation = str_pad(('[' . $severity[$this->severity] . ']'), 7) . str_pad($this->title, 40) . ' - ' . substr($this->value, 0, 30);
125  return $stringRepresentation;
126  }
127 }
__construct($title, $value, $message='', $severity=self::OK)
Definition: Status.php:61
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:31