TYPO3 CMS  TYPO3_7-6
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  */
16 
20 class Status
21 {
22  const NOTICE = -2;
23  const INFO = -1;
24  const OK = 0;
25  const WARNING = 1;
26  const ERROR = 2;
27 
31  protected $title;
32 
36  protected $value;
37 
41  protected $message;
42 
46  protected $severity;
47 
60  public function __construct($title, $value, $message = '', $severity = self::OK)
61  {
62  $this->title = (string)$title;
63  $this->value = (string)$value;
64  $this->message = (string)$message;
65  $this->severity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($severity, self::NOTICE, self::ERROR, self::OK);
66  }
67 
73  public function getTitle()
74  {
75  return $this->title;
76  }
77 
83  public function getValue()
84  {
85  return $this->value;
86  }
87 
93  public function getMessage()
94  {
95  return $this->message;
96  }
97 
103  public function getSeverity()
104  {
105  return $this->severity;
106  }
107 
113  public function __toString()
114  {
115  $severity = [
116  self::NOTICE => 'NOTE',
117  self::INFO => 'INFO',
118  self::OK => 'OK',
119  self::WARNING => 'WARN',
120  self::ERROR => 'ERR'
121  ];
122  // Max length 80 characters
123  $stringRepresentation = str_pad(('[' . $severity[$this->severity] . ']'), 7) . str_pad($this->title, 40) . ' - ' . substr($this->value, 0, 30);
124  return $stringRepresentation;
125  }
126 }
__construct($title, $value, $message='', $severity=self::OK)
Definition: Status.php:60
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:31