d26c7d069de226fe1d500b4619f626f116bd72fb
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Error / Message.php
1 <?php
2
3 /* *
4 * This script belongs to the Extbase framework *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 /**
24 */
25
26 /**
27 * An object representation of a generic message. Usually, you will use Error, Warning or Notice instead of this one.
28 *
29 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
30 * @api
31 */
32 class Tx_Extbase_Error_Message {
33
34 /**
35 * The default (english) error message
36 * @var string
37 */
38 protected $message = 'Unknown message';
39
40 /**
41 * The error code
42 * @var string
43 */
44 protected $code;
45
46 /**
47 * Constructs this error
48 *
49 * @param string $message An english error message which is used if no other error message can be resolved
50 * @param integer $code A unique error code
51 * @author Robert Lemke <robert@typo3.org>
52 * @api
53 */
54 public function __construct($message, $code) {
55 $this->message = $message;
56 $this->code = $code;
57 }
58
59 /**
60 * Returns the error message
61 * @return string The error message
62 * @author Andreas Förthner <andreas.foerthner@netlogix.de>
63 * @api
64 */
65 public function getMessage() {
66 return $this->message;
67 }
68
69 /**
70 * Returns the error code
71 * @return string The error code
72 * @author Andreas Förthner <andreas.foerthner@netlogix.de>
73 * @api
74 */
75 public function getCode() {
76 return $this->code;
77 }
78
79 /**
80 * Converts this error into a string
81 *
82 * @return string
83 * @author Robert Lemke <robert@typo3.org>
84 * @api
85 */
86 public function __toString() {
87 return $this->message . ' (#' . $this->code . ')';
88 }
89 }
90
91 ?>