TYPO3 CMS  TYPO3_6-2
AbstractMessage.php
Go to the documentation of this file.
1 <?php
3 
22 abstract class AbstractMessage {
23 
24  const NOTICE = -2;
25  const INFO = -1;
26  const OK = 0;
27  const WARNING = 1;
28  const ERROR = 2;
34  protected $title = '';
35 
41  protected $message = '';
42 
48  protected $severity = self::OK;
49 
55  public function getTitle() {
56  return $this->title;
57  }
58 
65  public function setTitle($title) {
66  $this->title = (string) $title;
67  }
68 
74  public function getMessage() {
75  return $this->message;
76  }
77 
84  public function setMessage($message) {
85  $this->message = (string) $message;
86  }
87 
93  public function getSeverity() {
94  return $this->severity;
95  }
96 
103  public function setSeverity($severity = self::OK) {
104  $this->severity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($severity, self::NOTICE, self::ERROR, self::OK);
105  }
106 
113  public function __toString() {
114  $severities = array(
115  self::INFO => 'INFO',
116  self::OK => 'OK',
117  self::WARNING => 'WARNING',
118  self::ERROR => 'ERROR'
119  );
120  $title = '';
121  if (!empty($this->title)) {
122  $title = ' - ' . $this->title;
123  }
124  return $severities[$this->severity] . $title . ': ' . $this->message;
125  }
126 
127 }
static forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32