File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace GetCandy \Client \Responses ;
44
5+ use ArrayAccess ;
56use Illuminate \Support \Collection ;
67use Illuminate \Contracts \Support \Arrayable ;
78
8- class ResponseObject implements Arrayable
9+ class ResponseObject implements Arrayable, ArrayAccess
910{
1011 protected $ attributes = [];
1112
@@ -55,4 +56,49 @@ public function toArray()
5556
5657 return $ data ;
5758 }
59+
60+ /**
61+ * Determine if the given attribute exists.
62+ *
63+ * @param mixed $offset
64+ * @return bool
65+ */
66+ public function offsetExists ($ offset )
67+ {
68+ return ! is_null ($ this ->getAttribute ($ offset ));
69+ }
70+
71+ /**
72+ * Get the value for a given offset.
73+ *
74+ * @param mixed $offset
75+ * @return mixed
76+ */
77+ public function offsetGet ($ offset )
78+ {
79+ return $ this ->getAttribute ($ offset );
80+ }
81+
82+ /**
83+ * Set the value for a given offset.
84+ *
85+ * @param mixed $offset
86+ * @param mixed $value
87+ * @return void
88+ */
89+ public function offsetSet ($ offset , $ value )
90+ {
91+ $ this ->setAttribute ($ offset , $ value );
92+ }
93+
94+ /**
95+ * Unset the value for a given offset.
96+ *
97+ * @param mixed $offset
98+ * @return void
99+ */
100+ public function offsetUnset ($ offset )
101+ {
102+ unset($ this ->attributes [$ offset ], $ this ->relations [$ offset ]);
103+ }
58104}
You can’t perform that action at this time.
0 commit comments