forked from youngguns-nl/moneybird_php_api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Disclosure.php
45 lines (34 loc) · 994 Bytes
/
Disclosure.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
<?php
/**
* Disclosure is a class meant for communication between Domain Objects and the
* views that are to display the values of those domain models.
*
* The rationale is that the Domain Object does not have to disclose any properties
* it doesn't want to, and as such, no longer has need for accessors or mutators.
* The disclosure should only be used in the view layer.
*/
namespace Moneybird;
/**
* Disclosure
*/
class Disclosure {
protected $values;
public function __construct($values) {
$this->values = $values;
}
public function toArray() {
return $this->values;
}
public function __get($key) {
if (array_key_exists($key, $this->values)) {
return $this->values[$key];
}
throw new Exception('Property '.$key.' has not been disclosed');
}
public function __set($key, $value) {
throw new Exception('A disclosure is read-only, don\'t try to write to it.');
}
public function __isset($key) {
return array_key_exists($key, $this->values);
}
}