1: <?php
2:
3: namespace Deimos\Session;
4:
5: use Deimos\Builder\Builder;
6: use Deimos\Helper\Traits\Helper;
7: use Deimos\Session\Extensions\Variable;
8:
9: abstract class Extension
10: {
11:
12: use Helper;
13: use Variable;
14:
15: /**
16: * Session constructor.
17: *
18: * @param Builder $builder
19: */
20: public function __construct(Builder $builder)
21: {
22: $this->builder = $builder;
23:
24: $this->init();
25: }
26:
27: /**
28: * @param string $name
29: * @param mixed $value
30: *
31: * @throws \InvalidArgumentException
32: */
33: public function set($name, $value)
34: {
35: $this->helper()->arr()->set($this->object, $name, $value);
36: }
37:
38: /**
39: * @param string $name
40: *
41: * @return bool
42: */
43: public function remove($name)
44: {
45: if (isset($this->{$name}))
46: {
47: unset($this->object[$name]);
48:
49: return true;
50: }
51:
52: return false;
53: }
54:
55: /**
56: * remove all keys
57: */
58: public final function removeAll()
59: {
60: foreach ($this->object() as $name => &$value)
61: {
62: $this->remove($name);
63: }
64: }
65:
66: /**
67: * @param string $name
68: *
69: * @return mixed
70: */
71: abstract public function __get($name);
72:
73: /**
74: * @param string $name
75: *
76: * @return bool
77: */
78: abstract public function __isset($name);
79:
80: /**
81: * @param string $name
82: * @param mixed $value
83: */
84: abstract public function __set($name, $value);
85:
86: }