1 | <?php |
||
12 | class FileRawResponsePersistenceHandler implements PersistenceHandler |
||
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 | private $path = ''; |
||
19 | |||
20 | private $spiderId = ''; |
||
21 | |||
22 | private $totalSizePersisted = 0; |
||
23 | |||
24 | /** @var \Iterator */ |
||
25 | private $iterator; |
||
26 | |||
27 | /** |
||
28 | * @param string $path the path where all spider results should be persisted. |
||
29 | * The results will be grouped in a directory by spider ID. |
||
30 | */ |
||
31 | public function __construct($path) |
||
35 | |||
36 | public function setSpiderId($spiderId) |
||
45 | |||
46 | public function count() |
||
50 | |||
51 | private function getResultPath() |
||
55 | |||
56 | public function persist(Resource $resource) |
||
63 | |||
64 | private function getFinder() |
||
71 | |||
72 | private function getIterator() |
||
79 | |||
80 | /** |
||
81 | * @return Resource |
||
82 | */ |
||
83 | public function current() |
||
87 | |||
88 | /** |
||
89 | * @return void |
||
90 | */ |
||
91 | public function next() |
||
95 | |||
96 | /** |
||
97 | * @return int |
||
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 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: