-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseObject.php
More file actions
44 lines (36 loc) · 820 Bytes
/
BaseObject.php
File metadata and controls
44 lines (36 loc) · 820 Bytes
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
<?php
class BaseObject
{
public function __construct($config=[])
{
$this->setConfig($config);
}
public function setConfig($config)
{
foreach($config as $key => $value) {
$this->$key = $value;
}
$this->init();
}
public function init()
{
}
public function __set($name, $value)
{
$setter = 'set' . ucfirst($name);
if (method_exists($this, $setter)) {
$this->$setter($name, $value);
return $this;
}
$this->$name = $value;
return $this;
}
public function __get($name)
{
$getter = 'get' . ucfirst($name);
if (method_exists($this, $getter)) {
return $this->$getter($name);
}
return $this->$name;
}
}