1: <?php
2:
3: namespace Deimos\Session;
4:
5: use Deimos\Session\Extensions\Flash;
6:
7: class Session extends Extension
8: {
9:
10: use Flash;
11:
12: /**
13: * @param string $name
14: * @param null $default
15: *
16: * @return mixed
17: *
18: * @throws \InvalidArgumentException
19: */
20: public function get($name, $default = null)
21: {
22: return $this->helper()->arr()->get($this->asArray(), $name, $default);
23: }
24:
25: /**
26: * @param string $name
27: *
28: * @return mixed
29: *
30: * @throws \Deimos\Helper\Exceptions\ExceptionEmpty
31: * @throws \InvalidArgumentException
32: */
33: public function getRequired($name)
34: {
35: return $this->helper()->arr()->getRequired($this->asArray(), $name);
36: }
37:
38: /**
39: * Alias getRequired($name)
40: *
41: * @param string $name
42: *
43: * @return mixed
44: *
45: * @throws \InvalidArgumentException
46: */
47: public function __get($name)
48: {
49: return $this->get($name);
50: }
51:
52: /**
53: * @param string $name
54: * @param mixed $value
55: */
56: public function __set($name, $value)
57: {
58: $this->set($name, $value);
59: }
60:
61: /**
62: * @param string $name
63: *
64: * @return bool
65: *
66: * @throws \InvalidArgumentException
67: */
68: public function __isset($name)
69: {
70: return $this->helper()->arr()->keyExists($this->asArray(), $name);
71: }
72:
73: /**
74: * @return array
75: */
76: public function asArray()
77: {
78: return $this->object() ?: [];
79: }
80:
81: }