1: <?php
2:
3: namespace Deimos\Cookie\Extensions;
4:
5: trait Variable
6: {
7:
8: /**
9: * @var array
10: */
11: private $object;
12:
13: /**
14: * @var bool
15: */
16: private $init;
17:
18: /**
19: * @return bool
20: */
21: private function init()
22: {
23: if (!$this->init)
24: {
25: global $_COOKIE;
26:
27: $this->init = true;
28: $this->object = &$_COOKIE;
29: }
30:
31: return !$this->init;
32: }
33:
34: /**
35: * @param string $variable
36: *
37: * @return mixed
38: */
39: protected function normalize($variable)
40: {
41: return preg_replace('~\.(\w+)~', '[$1]', $variable);
42: }
43:
44: /**
45: * @return array
46: */
47: protected function &object()
48: {
49: return $this->object;
50: }
51:
52: }