|
@@ -6,20 +6,30 @@ use Dever;
|
|
|
|
|
|
class Data implements Core
|
|
|
{
|
|
|
- private $db;
|
|
|
+ private $data = array();
|
|
|
+
|
|
|
+ private function init($key)
|
|
|
+ {
|
|
|
+ if (empty($this->data[$key])) {
|
|
|
+ $this->data[$key] = array();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public function push($value, $key)
|
|
|
{
|
|
|
- return array_push($this->db[$key], $value);
|
|
|
+ $this->init($key);
|
|
|
+ return array_push($this->data[$key], $value);
|
|
|
}
|
|
|
|
|
|
public function pop($key)
|
|
|
{
|
|
|
- return array_shift($this->db[$key]);
|
|
|
+ $this->init($key);
|
|
|
+ return array_shift($this->data[$key]);
|
|
|
}
|
|
|
|
|
|
public function len($key)
|
|
|
{
|
|
|
- return count($this->db[$key]);
|
|
|
+ $this->init($key);
|
|
|
+ return count($this->data[$key]);
|
|
|
}
|
|
|
}
|