-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCoreComm.php
110 lines (89 loc) · 2.51 KB
/
CoreComm.php
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
<?php
require_once('CoreDebug.php');
/**
* Used as a form of standard communication between different classes of
* the CorePrint library.
*/
class CoreComm {
/**
* Message of the communication.
* Should house a string version of the message.
* Suitable for output to a user.
*
* @var string
*/
public $TEXT = '';
/**
* The type of message
*
* @var type
*/
public $TYPE = '';
/**
* The result of the communication
* stored as a boolean. Primarily used when the
* CoreComm needs to indicate success or failure.
*
* @var type
*/
public $RESULT = false;
/**
* Used when a code is associated with the communication.
* Most often used for logging.
*
* @var type
*/
public $CODE = 0;
/**
* Stores the provided parameters.
* Used by the output log functionality.
*
* @var array
*/
private $PARAMS = array();
/**
* If a LOG property is contained in the
* params array then upon generation of the communication
* the comunication will be logged.
* This property should contain the name of the log, not the entry contents.
*
* @var type
*/
private $LOG = '';
/**
* Accepts a keyed array;
* Available keys:
* TEXT, TYPE, RESULT, CODE, LOG
* Which are paired with the associated properties.
*
* @param array $param
*/
function __construct($params) {
$this->PARAMS = $params;
if(array_key_exists('TEXT', $params)) { $this->TEXT = $params['TEXT']; }
if(array_key_exists('TYPE', $params)) { $this->TYPE = $params['TYPE']; }
if(array_key_exists('RESULT', $params)) { $this->RESULT = $params['RESULT']; }
if(array_key_exists('CODE', $params)) { $this->CODE = $params['CODE']; }
if(array_key_exists('LOG', $params)) {
$this->LOG = $params['LOG'];
$this->generateLog();
}
}
/**
* Outputs a log of the CoreComm details.
* This is not autoamtically logged but provides an easy entry of this logs
* content.
*
* @return array
*/
public function outputLog() {
return print_r($this->PARAMS, true);
}
/**
* Generates a log of the communication to the deisgnated log
*/
private function generateLog() {
CoreLog::add(print_r($this->PARAMS, true), $this->LOG);
}
}
?>