-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayAccessIterator.php
More file actions
68 lines (53 loc) · 1.47 KB
/
ArrayAccessIterator.php
File metadata and controls
68 lines (53 loc) · 1.47 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Created by JetBrains PhpStorm.
* User: incubator
* Date: 6/27/13
* Time: 10:11 AM
* To change this template use File | Settings | File Templates.
*/
class ArrayAccessIterator implements ArrayAccess, Iterator {
private $position = 0;
private $container = array();
public function __construct() {
$this->date = date('Y-m-d');
$fhandle = fopen('logs/'.$this->date, 'r+');
if($fhandle) {
$line = fgets($fhandle);
$data = explode("\t", $line);
$this->timestamp = $data[0];
$this->ip = $data[1];
$this->url = $data[2];
$this->session_id = $data[3];
}
}
public function offsetSet($offset, $value) {
if(is_null($offset)) {
$this->container[] = $value;
}else {
$this->container[$offset] = $value;
}
}
public function offsetGet($offset) {
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
public function offsetExists($offset) {
return isset($this->container[$offset]);
}
public function offsetUnset($offset) {
unset($this->container[$offset]);
}
public function valid() {
}
public function next() {
++$this->position;
}
public function current() {
return $this->container[$this->position];
}
public function rewind() {
++$this->position;
}
public function key() {
}
}