-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.php
More file actions
131 lines (111 loc) · 3.58 KB
/
Main.php
File metadata and controls
131 lines (111 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
namespace CB;
/**
* Main_Ex class
* @author Anjanesh Lekshminarayanan
* @modified 01/10/2007
*/
class Main_Ex extends \Exception
{
const E_UNKNOWN = 0;
const E_NOT_SET = 1;
const E_EMPTY_VALUE = 2;
const E_BAD_DATATYPE = 3;
const E_NOT_NUMERIC = 4;
const E_OUTOFBOUNDS = 5;
const E_DB_SQL = 6;
const E_NO_SETTER = 7;
const E_NO_GETTER = 8;
const E_EMPTY_STRING = 9;
const E_NOT_ARRAY = 10;
const E_NOT_INT = 11;
const E_BAD_COUNT = 12;
const E_EMPTY_ARG = 13;
const E_ARRAYINDEX_OUTOFBOUNDS = 14;
/*
Constructor
Parameters :
code (int) One of the error code constants E_*
[message] (string) Optional - override error message with custom message
Returns : none
Example : throw new SJS_Base_Ex(SJS_Base_Ex::E_NOT_NUMERIC);
*/
public function __construct($code = self::E_UNKNOWN, $message = NULL)
{
switch ($code)
{
case self::E_EMPTY_VALUE:
$msg = "Value cannot be blank";
break;
case self::E_EMPTY_STRING:
$msg = "String cannot be empty";
break;
case self::E_EMPTY_ARG:
$msg = "Argument cannot be empty";
break;
case self::E_DB_SQL:
$msg = "DB SQL Error";
break;
case self::E_NOT_SET:
$msg = "Variable must be assigned a value";
break;
case self::E_NO_SETTER:
$msg = "No setter available";
break;
case self::E_NO_GETTER:
$msg = "No getter available";
break;
case self::E_BAD_DATATYPE:
$msg = "Bad Data Type";
break;
case self::E_NOT_NUMERIC:
$msg = "Bad Data Type: Expected a Numeric Type";
break;
case self::E_OUTOFBOUNDS:
$msg = "Value is out of Bounds";
break;
case self::E_NOT_ARRAY:
$msg = "Expected an Array type.";
break;
case self::E_NOT_INT:
$msg = "Bad Data Type: Expected an Integer Type";
break;
case self::E_BAD_COUNT:
$msg = "Wrong Count";
break;
case self::E_ARRAYINDEX_OUTOFBOUNDS:
$msg = "Array Index is Out-Of-Bounds";
break;
case self::E_UNKNOWN: default:
$msg = "An unknown message has occurred";
break;
}
if (isset($message)) $msg .= ".\n$message."; # Add extra message to default message line
parent::__construct($msg, $code);
}
}
/**
* Main class
* @author Anjanesh Lekshminarayanan
* @modified 01/09/2007
* @description Base class for all classes
*/
abstract class Main
{
const DEBUG_FILENAME = "debug.log";
/*
Parameters :
str - the contents to be written - the time is inserted in the function
Filename - the filename to which the contents need to be written - the default one is DEBUG_FILENAME constant
*/
public static function log($str, $Filename = self::DEBUG_FILENAME)
{
$debug = debug_backtrace();
/*
$fh = fopen($Filename, "a");
fwrite($fh, @date("d-m-Y H:i:s")."\n$str\n\ndebug_backtrace() = ".print_r($debug, TRUE).str_repeat("=", 100)."\n");
fclose($fh);
*/
}
}
?>