This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | namespace JonnyW\PhantomJs; |
||
10 | |||
11 | use JonnyW\PhantomJs\Exception\InvalidExecutableException; |
||
12 | |||
13 | /** |
||
14 | * PHP PhantomJs |
||
15 | * |
||
16 | * @author Jon Wenmoth <[email protected]> |
||
17 | */ |
||
18 | class Engine |
||
19 | { |
||
20 | /** |
||
21 | * Executable path. |
||
22 | * |
||
23 | * @var string |
||
24 | * @access protected |
||
25 | */ |
||
26 | protected $path; |
||
27 | |||
28 | /** |
||
29 | * Debug flag. |
||
30 | * |
||
31 | * @var boolean |
||
32 | * @access protected |
||
33 | */ |
||
34 | protected $debug; |
||
35 | |||
36 | /** |
||
37 | * Cache flag. |
||
38 | * |
||
39 | * @var boolean |
||
40 | * @access protected |
||
41 | */ |
||
42 | protected $cache; |
||
43 | |||
44 | /** |
||
45 | * PhantomJs run options. |
||
46 | * |
||
47 | * @var array |
||
48 | * @access protected |
||
49 | */ |
||
50 | protected $options; |
||
51 | |||
52 | /** |
||
53 | * Log info |
||
54 | * |
||
55 | * @var string |
||
56 | * @access protected |
||
57 | */ |
||
58 | protected $log; |
||
59 | |||
60 | /** |
||
61 | * Internal constructor |
||
62 | * |
||
63 | * @access public |
||
64 | * @return void |
||
0 ignored issues
–
show
|
|||
65 | */ |
||
66 | 27 | public function __construct() |
|
67 | { |
||
68 | 27 | $this->path = 'bin/phantomjs'; |
|
69 | 27 | $this->options = array(); |
|
70 | |||
71 | 27 | $this->debug = false; |
|
72 | 27 | $this->cache = true; |
|
73 | 27 | } |
|
74 | |||
75 | /** |
||
76 | * Get PhantomJs run command with |
||
77 | * loader run options. |
||
78 | * |
||
79 | * @access public |
||
80 | * @return string |
||
81 | */ |
||
82 | 55 | public function getCommand() |
|
83 | { |
||
84 | 55 | $path = $this->getPath(); |
|
85 | 55 | $options = $this->getOptions(); |
|
86 | |||
87 | 55 | $this->validateExecutable($path); |
|
88 | |||
89 | 54 | if ($this->cache) { |
|
90 | 53 | array_push($options, '--disk-cache=true'); |
|
91 | 53 | } |
|
92 | |||
93 | 54 | if ($this->debug) { |
|
94 | 14 | array_push($options, '--debug=true'); |
|
95 | 14 | } |
|
96 | |||
97 | 54 | return sprintf('%s %s', $path, implode(' ', $options)); |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * Set path. |
||
102 | * |
||
103 | * @access public |
||
104 | * @param string $path |
||
105 | * @return \JonnyW\PhantomJs\Client |
||
106 | */ |
||
107 | 1 | public function setPath($path) |
|
108 | { |
||
109 | 1 | $this->validateExecutable($path); |
|
110 | |||
111 | $this->path = $path; |
||
112 | |||
113 | return $this; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Get path. |
||
118 | * |
||
119 | * @access public |
||
120 | * @return string |
||
121 | */ |
||
122 | 56 | public function getPath() |
|
123 | { |
||
124 | 56 | return $this->path; |
|
125 | } |
||
126 | |||
127 | /** |
||
128 | * Set PhantomJs run options. |
||
129 | * |
||
130 | * @access public |
||
131 | * @param array $options |
||
132 | * @return \JonnyW\PhantomJs\Client |
||
133 | */ |
||
134 | 1 | public function setOptions(array $options) |
|
135 | { |
||
136 | 1 | $this->options = $options; |
|
137 | |||
138 | 1 | return $this; |
|
139 | } |
||
140 | |||
141 | /** |
||
142 | * Get PhantomJs run options. |
||
143 | * |
||
144 | * @access public |
||
145 | * @return array |
||
146 | */ |
||
147 | 56 | public function getOptions() |
|
148 | { |
||
149 | 56 | return (array) $this->options; |
|
150 | } |
||
151 | |||
152 | /** |
||
153 | * Add single PhantomJs run option. |
||
154 | * |
||
155 | * @access public |
||
156 | * @param string $option |
||
157 | * @return \JonnyW\PhantomJs\Client |
||
158 | */ |
||
159 | 6 | public function addOption($option) |
|
160 | { |
||
161 | 6 | if (!in_array($option, $this->options)) { |
|
162 | 4 | $this->options[] = $option; |
|
163 | 4 | } |
|
164 | |||
165 | 6 | return $this; |
|
166 | } |
||
167 | |||
168 | /** |
||
169 | * Debug. |
||
170 | * |
||
171 | * @access public |
||
172 | * @param boolean $doDebug |
||
173 | * @return \JonnyW\PhantomJs\Client |
||
174 | */ |
||
175 | 4 | public function debug($doDebug) |
|
176 | { |
||
177 | 4 | $this->debug = $doDebug; |
|
178 | |||
179 | 4 | return $this; |
|
180 | } |
||
181 | |||
182 | /** |
||
183 | * Cache. |
||
184 | * |
||
185 | * @access public |
||
186 | * @param boolean $doCache |
||
187 | * @return \JonnyW\PhantomJs\Client |
||
188 | */ |
||
189 | 2 | public function cache($doCache) |
|
190 | { |
||
191 | 2 | $this->cache = $doCache; |
|
192 | |||
193 | 2 | return $this; |
|
194 | } |
||
195 | |||
196 | /** |
||
197 | * Log info. |
||
198 | * |
||
199 | * @access public |
||
200 | * @param string $info |
||
201 | * @return \JonnyW\PhantomJs\Client |
||
202 | */ |
||
203 | 49 | public function log($info) |
|
204 | { |
||
205 | 49 | $this->log = $info; |
|
206 | |||
207 | 49 | return $this; |
|
208 | } |
||
209 | |||
210 | /** |
||
211 | * Get log info. |
||
212 | * |
||
213 | * @access public |
||
214 | * @return string |
||
215 | */ |
||
216 | 11 | public function getLog() |
|
217 | { |
||
218 | 11 | return $this->log; |
|
219 | } |
||
220 | |||
221 | /** |
||
222 | * Clear log info. |
||
223 | * |
||
224 | * @access public |
||
225 | * @return \JonnyW\PhantomJs\Client |
||
226 | */ |
||
227 | 1 | public function clearLog() |
|
228 | { |
||
229 | 1 | $this->log = ''; |
|
230 | |||
231 | 1 | return $this; |
|
232 | } |
||
233 | |||
234 | /** |
||
235 | * Validate execuable file. |
||
236 | * |
||
237 | * @access private |
||
238 | * @param string $file |
||
239 | * @return boolean |
||
240 | * @throws \JonnyW\PhantomJs\Exception\InvalidExecutableException |
||
241 | */ |
||
242 | 56 | private function validateExecutable($file) |
|
243 | { |
||
244 | 56 | if (!file_exists($file) || !is_executable($file)) { |
|
245 | 2 | throw new InvalidExecutableException(sprintf('File does not exist or is not executable: %s', $file)); |
|
246 | } |
||
247 | |||
248 | 54 | return true; |
|
249 | } |
||
250 | } |
||
251 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.