1 | <?php |
||
12 | abstract class FilePersistenceHandler implements PersistenceHandlerInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var string the path where all spider results should be persisted. |
||
16 | * The results will be grouped in a directory by spider ID. |
||
17 | */ |
||
18 | protected $path = ''; |
||
19 | |||
20 | protected $spiderId = ''; |
||
21 | |||
22 | protected $totalSizePersisted = 0; |
||
23 | |||
24 | /** @var \Iterator */ |
||
25 | protected $iterator; |
||
26 | |||
27 | /** @var Finder */ |
||
28 | protected $finder; |
||
29 | |||
30 | /** |
||
31 | * @param string $path the path where all spider results should be persisted. |
||
32 | * The results will be grouped in a directory by spider ID. |
||
33 | */ |
||
34 | public function __construct($path) |
||
38 | |||
39 | public function setSpiderId($spiderId) |
||
48 | |||
49 | public function count() |
||
53 | |||
54 | protected function getResultPath() |
||
58 | |||
59 | abstract public function persist(Resource $resource); |
||
60 | |||
61 | /** |
||
62 | * @return Finder |
||
63 | */ |
||
64 | protected function getFinder() |
||
71 | |||
72 | /** |
||
73 | * @return \Iterator |
||
74 | */ |
||
75 | protected function getIterator() |
||
82 | |||
83 | /** |
||
84 | * @return Resource |
||
85 | */ |
||
86 | abstract public function current(); |
||
87 | |||
88 | /** |
||
89 | * @return void |
||
90 | */ |
||
91 | public function next() |
||
95 | |||
96 | /** |
||
97 | * @return integer|double|string|boolean|null |
||
98 | */ |
||
99 | public function key() |
||
103 | |||
104 | /** |
||
105 | * @return boolean |
||
106 | */ |
||
107 | public function valid() |
||
111 | |||
112 | /** |
||
113 | * @return void |
||
114 | */ |
||
115 | public function rewind() |
||
119 | } |
||
120 |