1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the feed-io package. |
4
|
|
|
* |
5
|
|
|
* (c) Alexandre Debril <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace FeedIo\Reader; |
12
|
|
|
|
13
|
|
|
use FeedIo\Adapter\ResponseInterface; |
14
|
|
|
use FeedIo\FeedInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Result of the read() operation |
18
|
|
|
* |
19
|
|
|
* a Result instance holds the following : |
20
|
|
|
* |
21
|
|
|
* - the Feed instance |
22
|
|
|
* - Date and time of the request |
23
|
|
|
* - value of the 'modifiedSince' header sent throught the request |
24
|
|
|
* - the raw response |
25
|
|
|
* - the DOM document |
26
|
|
|
* - URL of the feed |
27
|
|
|
*/ |
28
|
|
|
class Result |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var \DateTime |
33
|
|
|
*/ |
34
|
|
|
protected $modifiedSince; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var \DateTime |
38
|
|
|
*/ |
39
|
|
|
protected $date; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var \FeedIo\FeedInterface |
43
|
|
|
*/ |
44
|
|
|
protected $feed; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var \FeedIo\Adapter\ResponseInterface |
48
|
|
|
*/ |
49
|
|
|
protected $response; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var Document |
53
|
|
|
*/ |
54
|
|
|
protected $document; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
*/ |
59
|
|
|
protected $url; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param Document $document |
63
|
|
|
* @param FeedInterface $feed |
64
|
|
|
* @param \DateTime $modifiedSince |
65
|
|
|
* @param ResponseInterface $response |
66
|
|
|
* @param $url |
67
|
|
|
*/ |
68
|
2 |
|
public function __construct( |
69
|
|
|
Document $document, |
70
|
|
|
FeedInterface $feed, |
71
|
|
|
\DateTime $modifiedSince, |
72
|
|
|
ResponseInterface $response, |
73
|
|
|
$url |
74
|
|
|
) { |
75
|
2 |
|
$this->date = new \DateTime(); |
76
|
2 |
|
$this->document = $document; |
77
|
2 |
|
$this->feed = $feed; |
78
|
2 |
|
$this->modifiedSince = $modifiedSince; |
79
|
2 |
|
$this->response = $response; |
80
|
2 |
|
$this->url = $url; |
81
|
2 |
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return \DateTime |
85
|
|
|
*/ |
86
|
1 |
|
public function getDate() |
87
|
|
|
{ |
88
|
1 |
|
return $this->date; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return Document |
93
|
|
|
*/ |
94
|
1 |
|
public function getDocument() |
95
|
|
|
{ |
96
|
1 |
|
return $this->document; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return FeedInterface |
101
|
|
|
*/ |
102
|
2 |
|
public function getFeed() |
103
|
|
|
{ |
104
|
2 |
|
return $this->feed; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return \DateTime |
109
|
|
|
*/ |
110
|
1 |
|
public function getModifiedSince() |
111
|
|
|
{ |
112
|
1 |
|
return $this->modifiedSince; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return ResponseInterface |
117
|
|
|
*/ |
118
|
1 |
|
public function getResponse() |
119
|
|
|
{ |
120
|
1 |
|
return $this->response; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
1 |
|
public function getUrl() |
127
|
|
|
{ |
128
|
1 |
|
return $this->url; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|