Total Complexity | 6 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | class CollectionFile implements IteratorAggregate |
||
11 | { |
||
12 | /** |
||
13 | * 数据源 |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $path; |
||
18 | |||
19 | |||
20 | public static function fromFile(string $path) |
||
21 | { |
||
22 | $collection = new static; |
||
23 | $collection->path = $path; |
||
24 | return $collection; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * 保存到文件 |
||
29 | * |
||
30 | * @param string $path |
||
31 | * @return boolean |
||
32 | */ |
||
33 | public function save(string $path):bool |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * 获取迭代器 |
||
45 | * |
||
46 | * @return Iterator |
||
47 | */ |
||
48 | public function getIterator():Iterator |
||
56 |