1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Gorlum 08.01.2018 15:16 |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Common\Traits; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
trait TContainer { |
10
|
|
|
/** |
11
|
|
|
* @return \Common\Interfaces\IContainer |
12
|
|
|
*/ |
13
|
|
|
public function _getContainer() { |
14
|
|
|
return null; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function __set($name, $value) { |
18
|
|
|
is_object($this->_getContainer()) |
19
|
|
|
? $this->_getContainer()->__set($this->_containerTranslatePropertyName($name), $value) |
20
|
|
|
: null; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function __isset($name) { |
24
|
|
|
return is_object($this->_getContainer()) |
25
|
|
|
? $this->_getContainer()->__isset($this->_containerTranslatePropertyName($name)) |
26
|
|
|
: null; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function __get($name) { |
30
|
|
|
return is_object($this->_getContainer()) |
31
|
|
|
? $this->_getContainer()->__get($this->_containerTranslatePropertyName($name)) |
32
|
|
|
: null; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function __unset($name) { |
36
|
|
|
is_object($this->_getContainer()) |
37
|
|
|
? $this->_getContainer()->__unset($this->_containerTranslatePropertyName($name)) |
38
|
|
|
: null; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Is container contains no data |
43
|
|
|
* |
44
|
|
|
* @return bool |
45
|
|
|
*/ |
46
|
|
|
public function isEmpty() { |
47
|
|
|
return is_object($this->_getContainer()) ? $this->_getContainer()->isEmpty() : false; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Clears container contents |
52
|
|
|
*/ |
53
|
|
|
public function clear() { |
54
|
|
|
is_object($this->_getContainer()) ? $this->_getContainer()->clear() : null; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function __call($name, $arguments) { |
58
|
|
|
return is_object($this->_getContainer()) ? call_user_func_array([$this->_getContainer(), $name], $arguments) : null; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
protected function _containerTranslatePropertyName($name) { |
62
|
|
|
return $name; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|