|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the php-phantomjs. |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace JonnyW\PhantomJs\IO; |
|
11
|
|
|
|
|
12
|
|
|
use JonnyW\PhantomJs\Page\PaperSize; |
|
13
|
|
|
use JonnyW\PhantomJs\Page\ZoomFactor; |
|
14
|
|
|
use JonnyW\PhantomJs\Page\ViewportSize; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* PHP PhantomJs. |
|
18
|
|
|
* |
|
19
|
|
|
* @author Jon Wenmoth <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
trait OutputTrait |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Output logs. |
|
25
|
|
|
* |
|
26
|
|
|
* @var array |
|
27
|
|
|
*/ |
|
28
|
|
|
private $logs = []; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Settings. |
|
32
|
|
|
* |
|
33
|
|
|
* @var array |
|
34
|
|
|
*/ |
|
35
|
|
|
private $settings = []; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Create new output instance |
|
39
|
|
|
* with viewport size set. |
|
40
|
|
|
* |
|
41
|
|
|
* @param \JonnyW\PhantomJs\Page\ViewportSize $size |
|
42
|
|
|
* |
|
43
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
44
|
|
|
*/ |
|
45
|
|
|
public function withViewportSize(ViewportSize $size) |
|
46
|
|
|
{ |
|
47
|
|
|
$new = clone $this; |
|
48
|
|
|
$new->settings['page.viewportSize'] = $size; |
|
49
|
|
|
|
|
50
|
|
|
return $new; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Create new output instance |
|
55
|
|
|
* and unset viewport size. |
|
56
|
|
|
* |
|
57
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
58
|
|
|
*/ |
|
59
|
|
|
public function withoutViewportSize() |
|
60
|
|
|
{ |
|
61
|
|
|
$new = clone $this; |
|
62
|
|
|
|
|
63
|
|
|
unset($new->settings['page.viewportSize']); |
|
64
|
|
|
|
|
65
|
|
|
return $new; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Get viewport size. |
|
70
|
|
|
* |
|
71
|
|
|
* @return \JonnyW\PhantomJs\Page\ViewportSize |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getViewportSize() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->settings['page.viewportSize']; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Create new output instance |
|
80
|
|
|
* with paper size set. |
|
81
|
|
|
* |
|
82
|
|
|
* @param \JonnyW\PhantomJs\Page\PaperSize $size |
|
83
|
|
|
* |
|
84
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
85
|
|
|
*/ |
|
86
|
|
|
public function withPaperSize(PaperSize $size) |
|
87
|
|
|
{ |
|
88
|
|
|
$new = clone $this; |
|
89
|
|
|
$new->settings['page.paperSize'] = $size; |
|
90
|
|
|
|
|
91
|
|
|
return $new; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Create new output instance |
|
96
|
|
|
* and unset paper size. |
|
97
|
|
|
* |
|
98
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
99
|
|
|
*/ |
|
100
|
|
|
public function withoutPaperSize() |
|
101
|
|
|
{ |
|
102
|
|
|
$new = clone $this; |
|
103
|
|
|
|
|
104
|
|
|
unset($new->settings['page.paperSize']); |
|
105
|
|
|
|
|
106
|
|
|
return $new; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Get paper size. |
|
111
|
|
|
* |
|
112
|
|
|
* @return \JonnyW\PhantomJs\Page\PaperSize |
|
113
|
|
|
*/ |
|
114
|
|
|
public function getPaperSize() |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->settings['page.paperSize']; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Create new output instance |
|
121
|
|
|
* with zoom factor set. |
|
122
|
|
|
* |
|
123
|
|
|
* @param \JonnyW\PhantomJs\Page\ZoomFactor $zoom |
|
124
|
|
|
* |
|
125
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
126
|
|
|
*/ |
|
127
|
|
|
public function withZoomFactor(ZoomFactor $zoom) |
|
128
|
|
|
{ |
|
129
|
|
|
$new = clone $this; |
|
130
|
|
|
$new->settings['page.zoomFactor'] = $zoom; |
|
131
|
|
|
|
|
132
|
|
|
return $new; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* Create new output instance |
|
137
|
|
|
* and unset zoom factor. |
|
138
|
|
|
* |
|
139
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
140
|
|
|
*/ |
|
141
|
|
|
public function withoutZoomFactor() |
|
142
|
|
|
{ |
|
143
|
|
|
$new = clone $this; |
|
144
|
|
|
|
|
145
|
|
|
unset($new->settings['page.zoomFactor']); |
|
146
|
|
|
|
|
147
|
|
|
return $new; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Get zoom factor. |
|
152
|
|
|
* |
|
153
|
|
|
* @return \JonnyW\PhantomJs\Page\ZoomFactor |
|
154
|
|
|
*/ |
|
155
|
|
|
public function getZoomFactor() |
|
156
|
|
|
{ |
|
157
|
|
|
return $this->settings['page.zoomFactor']; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* Create new output instance |
|
162
|
|
|
* with clip rect set. |
|
163
|
|
|
* |
|
164
|
|
|
* @param \JonnyW\PhantomJs\Page\ClipRect $zoom |
|
165
|
|
|
* |
|
166
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
167
|
|
|
*/ |
|
168
|
|
|
public function withClipRect(ClipRect $zoom) |
|
169
|
|
|
{ |
|
170
|
|
|
$new = clone $this; |
|
171
|
|
|
$new->settings['page.clipRect'] = $zoom; |
|
172
|
|
|
|
|
173
|
|
|
return $new; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* Create new output instance |
|
178
|
|
|
* and unset clip rect. |
|
179
|
|
|
* |
|
180
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
181
|
|
|
*/ |
|
182
|
|
|
public function withoutClipRect() |
|
183
|
|
|
{ |
|
184
|
|
|
$new = clone $this; |
|
185
|
|
|
|
|
186
|
|
|
unset($new->settings['page.clipRect']); |
|
187
|
|
|
|
|
188
|
|
|
return $new; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Get clip rect. |
|
193
|
|
|
* |
|
194
|
|
|
* @return \JonnyW\PhantomJs\Page\ClipRect |
|
195
|
|
|
*/ |
|
196
|
|
|
public function getClipRect() |
|
197
|
|
|
{ |
|
198
|
|
|
return $this->settings['page.clipRect']; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* Create new output instance |
|
203
|
|
|
* with log entry added. |
|
204
|
|
|
* |
|
205
|
|
|
* @param string $line |
|
|
|
|
|
|
206
|
|
|
* |
|
207
|
|
|
* @return \JonnyW\PhantomJs\IO\OutputInterface |
|
208
|
|
|
*/ |
|
209
|
|
|
public function withLog($entry) |
|
210
|
|
|
{ |
|
211
|
|
|
$new = clone $this; |
|
212
|
|
|
$new->logs[] = $entry; |
|
213
|
|
|
|
|
214
|
|
|
return $new; |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
/** |
|
218
|
|
|
* Get log data. |
|
219
|
|
|
* |
|
220
|
|
|
* @return array |
|
221
|
|
|
*/ |
|
222
|
|
|
public function getLogs() |
|
223
|
|
|
{ |
|
224
|
|
|
return $this->logs; |
|
225
|
|
|
} |
|
226
|
|
|
} |
|
227
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.