1
|
|
|
<?php |
2
|
|
|
/******************************************************************** |
3
|
|
|
* Created by: Marko Kungla @ OkramLabs on Aug 6, 2012 - 9:12:38 |
4
|
|
|
* Contact: [email protected] - https://okramlabs.com |
5
|
|
|
* @copyright: 2015 OkramLabs - https://okramlabs.com |
6
|
|
|
* @license MIT |
7
|
|
|
* |
8
|
|
|
* Package name: libhowi-filesystem |
9
|
|
|
* @category HOWI3 |
10
|
|
|
* @package libhowi |
11
|
|
|
* @subpackage filesystem |
12
|
|
|
* |
13
|
|
|
* Lang: PHP |
14
|
|
|
* Encoding: UTF-8 |
15
|
|
|
* File: ResponseObject.inc |
16
|
|
|
* @link https://github.com/okramlabs/libhowi-filesystem |
17
|
|
|
******************************************************************** |
18
|
|
|
* Contributors: |
19
|
|
|
* @author Marko Kungla <[email protected]> |
20
|
|
|
* Github: https://github.com/mkungla |
21
|
|
|
******************************************************************** |
22
|
|
|
* Comments: |
23
|
|
|
* 1. This response trait is adjusted to follow structure of PSR-3. psr/log |
24
|
|
|
* see - https://github.com/php-fig/log |
25
|
|
|
*/ |
26
|
|
|
namespace HOWI3\libhowi\Filesystem\Commons; |
27
|
|
|
|
28
|
|
|
final class ResponseObject |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Filesystem status |
33
|
|
|
* |
34
|
|
|
* All filesystem methods have true/false states which are stored here |
35
|
|
|
* so it will only change when any messages are logged above minimum loglevel |
36
|
|
|
* |
37
|
|
|
* @var int $status |
38
|
|
|
*/ |
39
|
|
|
private $status = false; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Last log code |
43
|
|
|
* |
44
|
|
|
* Last logged message code |
45
|
|
|
* |
46
|
|
|
* @var int $code |
47
|
|
|
*/ |
48
|
|
|
private $code = 0; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Last log message |
52
|
|
|
* |
53
|
|
|
* Defaults to OK and further holds last logged message |
54
|
|
|
* |
55
|
|
|
* @var string $message |
56
|
|
|
*/ |
57
|
|
|
private $message = 'OK'; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Following is optional to have user id and username attached to log |
61
|
|
|
* Following can be anything you want for example your currently logged in |
62
|
|
|
* user info or system user running the script. |
63
|
|
|
* |
64
|
|
|
* @var unknown |
65
|
|
|
*/ |
66
|
|
|
private $UID = 0; |
67
|
|
|
|
68
|
|
|
private $username = 'anonymous'; |
69
|
|
|
|
70
|
|
|
private $context; |
71
|
|
|
|
72
|
|
|
private $level; |
73
|
|
|
|
74
|
|
|
|
75
|
731 |
|
public function setStatus($arg) |
76
|
|
|
{ |
77
|
731 |
|
$this->status = is_bool($arg) ? $arg : false; |
78
|
731 |
|
} |
79
|
|
|
|
80
|
731 |
|
public function setCode($code) |
81
|
|
|
{ |
82
|
731 |
|
$this->code = is_int($code) ? $code : 0; |
83
|
731 |
|
} |
84
|
|
|
|
85
|
731 |
|
public function setMsg($msg) |
86
|
|
|
{ |
87
|
731 |
|
$this->message = is_string($msg) ? $msg : 'BUG'; |
88
|
731 |
|
} |
89
|
|
|
|
90
|
731 |
|
public function setUID($UID) |
91
|
|
|
{ |
92
|
731 |
|
$this->UID = is_int($UID) ? $UID : 'BUG'; |
|
|
|
|
93
|
731 |
|
} |
94
|
|
|
|
95
|
731 |
|
public function setUsername($username) |
96
|
|
|
{ |
97
|
731 |
|
$this->username = is_string($username) ? $username : 'BUG'; |
98
|
731 |
|
} |
99
|
|
|
|
100
|
731 |
|
public function setTime() |
101
|
|
|
{ |
102
|
731 |
|
$this->microtime = microtime(true); |
|
|
|
|
103
|
731 |
|
} |
104
|
|
|
|
105
|
731 |
|
public function setContext($context) |
106
|
|
|
{ |
107
|
731 |
|
$this->context = $context; |
108
|
731 |
|
} |
109
|
|
|
|
110
|
731 |
|
public function setLevel($level) |
111
|
|
|
{ |
112
|
731 |
|
$this->level = $level; |
113
|
731 |
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
33 |
|
public function getStatus() |
117
|
|
|
{ |
118
|
33 |
|
return $this->status; |
119
|
|
|
} |
120
|
|
|
|
121
|
84 |
|
public function getCode() |
122
|
|
|
{ |
123
|
84 |
|
return $this->code; |
124
|
|
|
} |
125
|
|
|
|
126
|
66 |
|
public function getMsg() |
127
|
|
|
{ |
128
|
66 |
|
return $this->message; |
129
|
|
|
} |
130
|
|
|
|
131
|
3 |
|
public function getUID() |
132
|
|
|
{ |
133
|
3 |
|
return $this->UID; |
134
|
|
|
} |
135
|
|
|
|
136
|
3 |
|
public function getUsername() |
137
|
|
|
{ |
138
|
3 |
|
return $this->username; |
139
|
|
|
} |
140
|
|
|
|
141
|
63 |
|
public function getTime() |
142
|
|
|
{ |
143
|
63 |
|
return $this->microtime; |
144
|
|
|
} |
145
|
|
|
|
146
|
3 |
|
public function getContext() |
147
|
|
|
{ |
148
|
3 |
|
return $this->context; |
149
|
|
|
} |
150
|
|
|
|
151
|
3 |
|
public function getLevel() |
152
|
|
|
{ |
153
|
3 |
|
return $this->level; |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..