Object.class.php
1.18 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
<?php
/**
* Created by PhpStorm.
* User: Администратор
* Date: 17.03.14
* Time: 9:47
*/
namespace Cpeople\Classes\Base;
class Object
{
protected $data;
public function __construct($data = array())
{
if (!is_array($data))
{
throw new \Exception('Argument should be an array to ' . __METHOD__);
}
$this->data = $data;
}
public function __get($name)
{
if (isset($this->data[strtoupper($name)]))
{
return $this->data[strtoupper($name)];
}
$trace = debug_backtrace();
trigger_error(
'Undefined property in __get(): ' . $name .
' in file ' . $trace[0]['file'] .
' line ' . $trace[0]['line'], E_USER_NOTICE
);
}
public function unescape($name)
{
return html_entity_decode($this->{$name});
}
public function escape($name)
{
return $this->escaped($name);
}
public function escaped($name)
{
return htmlspecialchars($this->{$name});
}
public function getData()
{
return $this->data;
}
}