"Fossies" - the Fresh Open Source Software Archive 
Member "openmailadmin-1.0.1/inc/lib/ErrorHandler.php" (27 Feb 2006, 1468 Bytes) of package /linux/privat/old/openmailadmin-1.0.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "ErrorHandler.php" see the
Fossies "Dox" file reference documentation.
1 <?php
2 /**
3 * Provides some primitive functions for error handling each class has to implement.
4 * You are free to still use exceptions, where applicable, for critical/blocking errors.
5 */
6 class ErrorHandler
7 {
8 private $error = array(); // This will store any errors.
9 private $info = array(); // Array for informations.
10 private static $instance;
11
12 private function __construct() {
13 }
14
15 /**
16 * For singleton pattern.
17 */
18 public static function getInstance() {
19 if (!isset(self::$instance)) {
20 $classname = __CLASS__;
21 self::$instance = new $classname;
22 }
23 return self::$instance;
24 }
25
26 public function __clone() {
27 trigger_error('Only on instance allowed.', E_USER_ERROR);
28 }
29
30 /**
31 * Sets $errors to 'no errors occured' and $info to 'no info'.
32 */
33 public function status_reset() {
34 $this->error = array();
35 $this->info = array();
36 }
37
38 public function errors_occured() {
39 return (count($this->error) > 0);
40 }
41
42 public function info_occured() {
43 return (count($this->info) > 0);
44 }
45
46 /**
47 * Concatenates every error message.
48 */
49 public function errors_get() {
50 $err = implode(' ', $this->error);
51 return $err;
52 }
53
54 /**
55 * Concatenates every information message.
56 */
57 public function info_get() {
58 $err = implode(' ', $this->info);
59 return $err;
60 }
61
62 /**
63 * @access friend
64 */
65 public function add_info($text) {
66 $this->info[] = $text;
67 }
68
69 /**
70 * @access friend
71 */
72 public function add_error($text) {
73 $this->error[] = $text;
74 }
75
76 }
77 ?>