forked from ttoponce/assignment-4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMem.php
55 lines (41 loc) · 1008 Bytes
/
Mem.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
include "persistence_interface.php";
class Mem implements PersistenceInterface {
protected $buf;
public function Count(){
return count($this->buf);
}
public function Create($item){
$this->buf[] = $item;
}
public function Read($id){
$target = $this->prototype->Search($id, $this->buf);
return $target;
}
public function Delete($id){
unset($this->buf[$id]);
}
public function ReadAll(){
return $this->buf;
}
public function Update($id, $values){
//
}
public function __construct($item){
$this->type = gettype($item);
$this->prototype = $item;
$this->buf[$item->Asin] = $item;
}
public function All() {
return $this->buf;
}
public function Clear(){
unset($this->buf);
}
public function Insert($item = 0){
$this->buf[] = $item;
}
public function Remove($idx){
unset($this->buf[$idx]);
}
}