-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSimpleDirectoryIterator.php
More file actions
42 lines (36 loc) · 928 Bytes
/
Copy pathSimpleDirectoryIterator.php
File metadata and controls
42 lines (36 loc) · 928 Bytes
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
<?php
class SimpleDirectoryIterator extends ArchiveIterator {
protected $path=null;
protected $regex;
public function __construct()
{
}
/**
* @param string $path
* @param $regex
* @return SimpleDirectoryIterator
*/
public function setPath($path,$regex)
{
$this->path = $path;
$this -> regex = $regex;
return $this;
}
/**
* @return ArchiveItem[]
*/
public function getArchiveItems() {
$items = array();
//TODO : directoryIterator
if($dir = opendir($this->path)) {
while($file_name = readdir($dir)) {
if(preg_match($this->regex,$file_name,$match)) {
// var_dump($file_name);
$date = new DateTime($match[1]);
$items[] = new ArchiveItem($date);
}
}
}
return $items;
}
}