@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | if (!empty($params['page_size']) && !is_string($params['page_size'])) |
50 | 50 | throw new InvalidParameterException('Page size must be a string of some standard page size.'); |
51 | 51 | |
52 | - if (!empty($params['dpi']) && (!is_int($params['dpi']) || $params['dpi']<75)) |
|
52 | + if (!empty($params['dpi']) && (!is_int($params['dpi']) || $params['dpi'] < 75)) |
|
53 | 53 | throw new InvalidParameterException('DPI must be an integer larger than 75.'); |
54 | 54 | |
55 | 55 | if (!empty($params['image_dpi']) && !is_int($params['image_dpi'])) |
56 | 56 | throw new InvalidParameterException('Image DPI must be an integer.'); |
57 | 57 | |
58 | 58 | if (!empty($params['lowquality']) && (!is_int($params['lowquality']) || !in_array($params['lowquality'], array( |
59 | - 0, 1 ) ))) |
|
59 | + 0, 1 )))) |
|
60 | 60 | throw new InvalidParameterException( |
61 | 61 | 'Lowquality must be either 0 or 1 (alternative: use bool values'); |
62 | 62 | |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | throw new InvalidParameterException('Margin top must be an integer.'); |
78 | 78 | |
79 | 79 | if (!empty($params['background']) && (!is_int($params['background']) || !in_array($params['background'], array( |
80 | - 0, 1 ) ))) |
|
80 | + 0, 1 )))) |
|
81 | 81 | throw new InvalidParameterException( |
82 | 82 | 'Background must be either 0 or 1 (alternative: use bool values'); |
83 | 83 | |
84 | 84 | if (!empty($params['images']) && (!is_int($params['images']) || !in_array($params['images'], array( |
85 | - 0, 1 ) ))) |
|
85 | + 0, 1 )))) |
|
86 | 86 | throw new InvalidParameterException( |
87 | 87 | 'Images must be either 0 or 1 (alternative: use bool values'); |
88 | 88 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | throw new InvalidParameterException('Group must be a string.'); |
101 | 101 | |
102 | 102 | if (!empty($params['engine_version']) && (!is_int($params['engine_version']) || !in_array($params['engine_version'], |
103 | - array( 11, 12 ) ))) |
|
103 | + array(11, 12)))) |
|
104 | 104 | throw new InvalidParameterException( |
105 | 105 | 'Engine version can be integer 11 or 12'); |
106 | 106 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | throw new InvalidParameterException('Title must be a string.'); |
109 | 109 | |
110 | 110 | if (!empty($params['outline']) && (!is_int($params['outline']) || !in_array($params['outline'], array( |
111 | - 0, 1 ) ))) |
|
111 | + 0, 1 )))) |
|
112 | 112 | throw new InvalidParameterException( |
113 | 113 | 'Outline must be either 0 or 1 (alternative: use bool values'); |
114 | 114 | |
@@ -119,21 +119,21 @@ discard block |
||
119 | 119 | throw new InvalidParameterException('Encoding must be a string.'); |
120 | 120 | |
121 | 121 | if (!empty($params['javascript']) && (!is_int($params['javascript']) || !in_array($params['javascript'], array( |
122 | - 0, 1 ) ))) |
|
122 | + 0, 1 )))) |
|
123 | 123 | throw new InvalidParameterException( |
124 | 124 | 'Javascript must be either 0 or 1 (alternative: use bool values'); |
125 | 125 | |
126 | 126 | if (!empty($params['javascript_delay']) && |
127 | - (!is_int($params['javascript_delay']) || $params['javascript_delay']<1 || $params['javascript_delay']>800)) |
|
127 | + (!is_int($params['javascript_delay']) || $params['javascript_delay'] < 1 || $params['javascript_delay'] > 800)) |
|
128 | 128 | throw new InvalidParameterException('Javascript delay must be an integer larger than 1, but smaller than 800.'); |
129 | 129 | |
130 | 130 | if (!empty($params['internal_links']) && |
131 | - (!is_int($params['internal_links']) || !in_array($params['internal_links'], array( 0, 1 ) ))) |
|
131 | + (!is_int($params['internal_links']) || !in_array($params['internal_links'], array(0, 1)))) |
|
132 | 132 | throw new InvalidParameterException( |
133 | 133 | 'Internal links must be either 0 or 1 (alternative: use bool values'); |
134 | 134 | |
135 | 135 | if (!empty($params['external_links']) && |
136 | - (!is_int($params['external_links']) || !in_array($params['external_links'], array( 0, 1 ) ))) |
|
136 | + (!is_int($params['external_links']) || !in_array($params['external_links'], array(0, 1)))) |
|
137 | 137 | throw new InvalidParameterException( |
138 | 138 | 'External links must be either 0 or 1 (alternative: use bool values'); |
139 | 139 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | if (!empty($params['use_print_media']) && |
150 | 150 | (!is_int($params['use_print_media']) || !in_array($params['use_print_media'], array( |
151 | - 0, 1 ) ))) |
|
151 | + 0, 1 )))) |
|
152 | 152 | throw new InvalidParameterException( |
153 | 153 | 'Use print media must be either 0 or 1 (alternative: use bool values'); |
154 | 154 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | $path_parts = pathinfo($filePath); |
187 | 187 | |
188 | - if( !in_array($path_parts['extension'], array( |
|
188 | + if (!in_array($path_parts['extension'], array( |
|
189 | 189 | "js", "css", "png", "jpg", "jpeg", "gif", "ttf", "otf", "woff" |
190 | 190 | ))) |
191 | 191 | throw new WrongFileExtensionException("Wrong file format\n |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | $path_parts = pathinfo($filePath); |
211 | 211 | |
212 | - if( !in_array($path_parts['extension'], array( |
|
212 | + if (!in_array($path_parts['extension'], array( |
|
213 | 213 | "html", "htm", "zip", "tar.gz", "tgz", "tar.bz2" |
214 | 214 | ))) |
215 | 215 | throw new WrongFileExtensionException("Wrong file format\n |
@@ -20,147 +20,185 @@ discard block |
||
20 | 20 | { |
21 | 21 | $params = $this->boolParams($params); |
22 | 22 | |
23 | - if (!empty($params['html']) && (!empty($params['url']) || !empty($params['file']))) |
|
24 | - throw new InvalidParameterException("Only one of [html, url, file] parameters can be set!"); |
|
23 | + if (!empty($params['html']) && (!empty($params['url']) || !empty($params['file']))) { |
|
24 | + throw new InvalidParameterException("Only one of [html, url, file] parameters can be set!"); |
|
25 | + } |
|
25 | 26 | |
26 | - if (!empty($params['url']) && !empty($params['file'])) |
|
27 | - throw new InvalidParameterException("Only one of [html, url, file] parameters can be set!"); |
|
27 | + if (!empty($params['url']) && !empty($params['file'])) { |
|
28 | + throw new InvalidParameterException("Only one of [html, url, file] parameters can be set!"); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | if ((!empty($params['page_width']) && empty($params['page_height'])) |
30 | 32 | ||(empty($params['page_width']) && !empty($params['page_height']))) |
31 | 33 | { |
32 | 34 | throw new InvalidParameterException('Page width and page height must both be set or unset!'); |
33 | 35 | } |
34 | - if (!empty($params['filename']) && !is_string($params['filename'])) |
|
35 | - throw new InvalidParameterException('Filename must be a string.'); |
|
36 | + if (!empty($params['filename']) && !is_string($params['filename'])) { |
|
37 | + throw new InvalidParameterException('Filename must be a string.'); |
|
38 | + } |
|
36 | 39 | |
37 | - if (!empty($params['footer']) && !is_string($params['footer'])) |
|
38 | - throw new InvalidParameterException('Footer must be a string.'); |
|
40 | + if (!empty($params['footer']) && !is_string($params['footer'])) { |
|
41 | + throw new InvalidParameterException('Footer must be a string.'); |
|
42 | + } |
|
39 | 43 | |
40 | - if (!empty($params['header']) && !is_string($params['header'])) |
|
41 | - throw new InvalidParameterException('Header must be a string.'); |
|
44 | + if (!empty($params['header']) && !is_string($params['header'])) { |
|
45 | + throw new InvalidParameterException('Header must be a string.'); |
|
46 | + } |
|
42 | 47 | |
43 | - if (!empty($params['header_spacing']) && !is_int($params['header_spacing'])) |
|
44 | - throw new InvalidParameterException('Header spacing parameter must be an integer.'); |
|
48 | + if (!empty($params['header_spacing']) && !is_int($params['header_spacing'])) { |
|
49 | + throw new InvalidParameterException('Header spacing parameter must be an integer.'); |
|
50 | + } |
|
45 | 51 | |
46 | - if (!empty($params['footer_spacing']) && !is_int($params['footer_spacing'])) |
|
47 | - throw new InvalidParameterException('Footer spacing parameter must be an integer.'); |
|
52 | + if (!empty($params['footer_spacing']) && !is_int($params['footer_spacing'])) { |
|
53 | + throw new InvalidParameterException('Footer spacing parameter must be an integer.'); |
|
54 | + } |
|
48 | 55 | |
49 | - if (!empty($params['page_size']) && !is_string($params['page_size'])) |
|
50 | - throw new InvalidParameterException('Page size must be a string of some standard page size.'); |
|
56 | + if (!empty($params['page_size']) && !is_string($params['page_size'])) { |
|
57 | + throw new InvalidParameterException('Page size must be a string of some standard page size.'); |
|
58 | + } |
|
51 | 59 | |
52 | - if (!empty($params['dpi']) && (!is_int($params['dpi']) || $params['dpi']<75)) |
|
53 | - throw new InvalidParameterException('DPI must be an integer larger than 75.'); |
|
60 | + if (!empty($params['dpi']) && (!is_int($params['dpi']) || $params['dpi']<75)) { |
|
61 | + throw new InvalidParameterException('DPI must be an integer larger than 75.'); |
|
62 | + } |
|
54 | 63 | |
55 | - if (!empty($params['image_dpi']) && !is_int($params['image_dpi'])) |
|
56 | - throw new InvalidParameterException('Image DPI must be an integer.'); |
|
64 | + if (!empty($params['image_dpi']) && !is_int($params['image_dpi'])) { |
|
65 | + throw new InvalidParameterException('Image DPI must be an integer.'); |
|
66 | + } |
|
57 | 67 | |
58 | 68 | if (!empty($params['lowquality']) && (!is_int($params['lowquality']) || !in_array($params['lowquality'], array( |
59 | - 0, 1 ) ))) |
|
60 | - throw new InvalidParameterException( |
|
69 | + 0, 1 ) ))) { |
|
70 | + throw new InvalidParameterException( |
|
61 | 71 | 'Lowquality must be either 0 or 1 (alternative: use bool values'); |
72 | + } |
|
62 | 73 | |
63 | 74 | if (!empty($params['orientation']) && (!is_string($params['orientation']) || !in_array($params['orientation'], |
64 | - array("landscape", "portrait")))) |
|
65 | - throw new InvalidParameterException('Orientation must be set to either "landscape" or "portrait"'); |
|
75 | + array("landscape", "portrait")))) { |
|
76 | + throw new InvalidParameterException('Orientation must be set to either "landscape" or "portrait"'); |
|
77 | + } |
|
66 | 78 | |
67 | - if (!empty($params['margin_top']) && !is_int($params['margin_top'])) |
|
68 | - throw new InvalidParameterException('Margin top must be an integer.'); |
|
79 | + if (!empty($params['margin_top']) && !is_int($params['margin_top'])) { |
|
80 | + throw new InvalidParameterException('Margin top must be an integer.'); |
|
81 | + } |
|
69 | 82 | |
70 | - if (!empty($params['margin_bottom']) && !is_int($params['margin_bottom'])) |
|
71 | - throw new InvalidParameterException('Margin top must be an integer.'); |
|
83 | + if (!empty($params['margin_bottom']) && !is_int($params['margin_bottom'])) { |
|
84 | + throw new InvalidParameterException('Margin top must be an integer.'); |
|
85 | + } |
|
72 | 86 | |
73 | - if (!empty($params['margin_left']) && !is_int($params['margin_left'])) |
|
74 | - throw new InvalidParameterException('Margin top must be an integer.'); |
|
87 | + if (!empty($params['margin_left']) && !is_int($params['margin_left'])) { |
|
88 | + throw new InvalidParameterException('Margin top must be an integer.'); |
|
89 | + } |
|
75 | 90 | |
76 | - if (!empty($params['margin_right']) && !is_int($params['margin_right'])) |
|
77 | - throw new InvalidParameterException('Margin top must be an integer.'); |
|
91 | + if (!empty($params['margin_right']) && !is_int($params['margin_right'])) { |
|
92 | + throw new InvalidParameterException('Margin top must be an integer.'); |
|
93 | + } |
|
78 | 94 | |
79 | 95 | if (!empty($params['background']) && (!is_int($params['background']) || !in_array($params['background'], array( |
80 | - 0, 1 ) ))) |
|
81 | - throw new InvalidParameterException( |
|
96 | + 0, 1 ) ))) { |
|
97 | + throw new InvalidParameterException( |
|
82 | 98 | 'Background must be either 0 or 1 (alternative: use bool values'); |
99 | + } |
|
83 | 100 | |
84 | 101 | if (!empty($params['images']) && (!is_int($params['images']) || !in_array($params['images'], array( |
85 | - 0, 1 ) ))) |
|
86 | - throw new InvalidParameterException( |
|
102 | + 0, 1 ) ))) { |
|
103 | + throw new InvalidParameterException( |
|
87 | 104 | 'Images must be either 0 or 1 (alternative: use bool values'); |
105 | + } |
|
88 | 106 | |
89 | - if (!empty($params['page_width']) && !is_int($params['page_width'])) |
|
90 | - throw new InvalidParameterException('Page width must be an integer.'); |
|
107 | + if (!empty($params['page_width']) && !is_int($params['page_width'])) { |
|
108 | + throw new InvalidParameterException('Page width must be an integer.'); |
|
109 | + } |
|
91 | 110 | |
92 | - if (!empty($params['page_height']) && !is_int($params['page_height'])) |
|
93 | - throw new InvalidParameterException('Page height must be an integer.'); |
|
111 | + if (!empty($params['page_height']) && !is_int($params['page_height'])) { |
|
112 | + throw new InvalidParameterException('Page height must be an integer.'); |
|
113 | + } |
|
94 | 114 | |
95 | 115 | if (!empty($params['disposition']) && (!is_string($params['disposition']) || !in_array($params['disposition'], |
96 | - array("attachment", "inline")))) |
|
97 | - throw new InvalidParameterException('Disposition can only be "attachment or "inline"'); |
|
116 | + array("attachment", "inline")))) { |
|
117 | + throw new InvalidParameterException('Disposition can only be "attachment or "inline"'); |
|
118 | + } |
|
98 | 119 | |
99 | - if (!empty($params['group']) && !is_string($params['group'])) |
|
100 | - throw new InvalidParameterException('Group must be a string.'); |
|
120 | + if (!empty($params['group']) && !is_string($params['group'])) { |
|
121 | + throw new InvalidParameterException('Group must be a string.'); |
|
122 | + } |
|
101 | 123 | |
102 | 124 | if (!empty($params['engine_version']) && (!is_int($params['engine_version']) || !in_array($params['engine_version'], |
103 | - array( 11, 12 ) ))) |
|
104 | - throw new InvalidParameterException( |
|
125 | + array( 11, 12 ) ))) { |
|
126 | + throw new InvalidParameterException( |
|
105 | 127 | 'Engine version can be integer 11 or 12'); |
128 | + } |
|
106 | 129 | |
107 | - if (!empty($params['title']) && !is_string($params['title'])) |
|
108 | - throw new InvalidParameterException('Title must be a string.'); |
|
130 | + if (!empty($params['title']) && !is_string($params['title'])) { |
|
131 | + throw new InvalidParameterException('Title must be a string.'); |
|
132 | + } |
|
109 | 133 | |
110 | 134 | if (!empty($params['outline']) && (!is_int($params['outline']) || !in_array($params['outline'], array( |
111 | - 0, 1 ) ))) |
|
112 | - throw new InvalidParameterException( |
|
135 | + 0, 1 ) ))) { |
|
136 | + throw new InvalidParameterException( |
|
113 | 137 | 'Outline must be either 0 or 1 (alternative: use bool values'); |
138 | + } |
|
114 | 139 | |
115 | - if (!empty($params['outline_depth']) && !is_int($params['outline_depth'])) |
|
116 | - throw new InvalidParameterException('Outline depth must be an integer.'); |
|
140 | + if (!empty($params['outline_depth']) && !is_int($params['outline_depth'])) { |
|
141 | + throw new InvalidParameterException('Outline depth must be an integer.'); |
|
142 | + } |
|
117 | 143 | |
118 | - if (!empty($params['encoding']) && !is_string($params['encoding'])) |
|
119 | - throw new InvalidParameterException('Encoding must be a string.'); |
|
144 | + if (!empty($params['encoding']) && !is_string($params['encoding'])) { |
|
145 | + throw new InvalidParameterException('Encoding must be a string.'); |
|
146 | + } |
|
120 | 147 | |
121 | 148 | if (!empty($params['javascript']) && (!is_int($params['javascript']) || !in_array($params['javascript'], array( |
122 | - 0, 1 ) ))) |
|
123 | - throw new InvalidParameterException( |
|
149 | + 0, 1 ) ))) { |
|
150 | + throw new InvalidParameterException( |
|
124 | 151 | 'Javascript must be either 0 or 1 (alternative: use bool values'); |
152 | + } |
|
125 | 153 | |
126 | 154 | if (!empty($params['javascript_delay']) && |
127 | - (!is_int($params['javascript_delay']) || $params['javascript_delay']<1 || $params['javascript_delay']>800)) |
|
128 | - throw new InvalidParameterException('Javascript delay must be an integer larger than 1, but smaller than 800.'); |
|
155 | + (!is_int($params['javascript_delay']) || $params['javascript_delay']<1 || $params['javascript_delay']>800)) { |
|
156 | + throw new InvalidParameterException('Javascript delay must be an integer larger than 1, but smaller than 800.'); |
|
157 | + } |
|
129 | 158 | |
130 | 159 | if (!empty($params['internal_links']) && |
131 | - (!is_int($params['internal_links']) || !in_array($params['internal_links'], array( 0, 1 ) ))) |
|
132 | - throw new InvalidParameterException( |
|
160 | + (!is_int($params['internal_links']) || !in_array($params['internal_links'], array( 0, 1 ) ))) { |
|
161 | + throw new InvalidParameterException( |
|
133 | 162 | 'Internal links must be either 0 or 1 (alternative: use bool values'); |
163 | + } |
|
134 | 164 | |
135 | 165 | if (!empty($params['external_links']) && |
136 | - (!is_int($params['external_links']) || !in_array($params['external_links'], array( 0, 1 ) ))) |
|
137 | - throw new InvalidParameterException( |
|
166 | + (!is_int($params['external_links']) || !in_array($params['external_links'], array( 0, 1 ) ))) { |
|
167 | + throw new InvalidParameterException( |
|
138 | 168 | 'External links must be either 0 or 1 (alternative: use bool values'); |
169 | + } |
|
139 | 170 | |
140 | - if (!empty($params['page_offset']) && !is_int($params['page_offset'])) |
|
141 | - throw new InvalidParameterException('Page offset must be an integer.'); |
|
171 | + if (!empty($params['page_offset']) && !is_int($params['page_offset'])) { |
|
172 | + throw new InvalidParameterException('Page offset must be an integer.'); |
|
173 | + } |
|
142 | 174 | |
143 | - if (!empty($params['username']) && !is_string($params['username'])) |
|
144 | - throw new InvalidParameterException('Username must be a string.'); |
|
175 | + if (!empty($params['username']) && !is_string($params['username'])) { |
|
176 | + throw new InvalidParameterException('Username must be a string.'); |
|
177 | + } |
|
145 | 178 | |
146 | - if (!empty($params['password']) && !is_string($params['password'])) |
|
147 | - throw new InvalidParameterException('Password must be a string.'); |
|
179 | + if (!empty($params['password']) && !is_string($params['password'])) { |
|
180 | + throw new InvalidParameterException('Password must be a string.'); |
|
181 | + } |
|
148 | 182 | |
149 | 183 | if (!empty($params['use_print_media']) && |
150 | 184 | (!is_int($params['use_print_media']) || !in_array($params['use_print_media'], array( |
151 | - 0, 1 ) ))) |
|
152 | - throw new InvalidParameterException( |
|
185 | + 0, 1 ) ))) { |
|
186 | + throw new InvalidParameterException( |
|
153 | 187 | 'Use print media must be either 0 or 1 (alternative: use bool values'); |
188 | + } |
|
154 | 189 | |
155 | - if (!empty($params['zoom']) && !is_numeric($params['zoom'])) |
|
156 | - throw new InvalidParameterException('Zoom must be an integer.'); |
|
190 | + if (!empty($params['zoom']) && !is_numeric($params['zoom'])) { |
|
191 | + throw new InvalidParameterException('Zoom must be an integer.'); |
|
192 | + } |
|
157 | 193 | |
158 | 194 | if (!empty($params['viewport_size']) && |
159 | - (!is_string($params['viewport_size'] || preg_match("^\\d+x\\d+$", $params['viewport_size'])))) |
|
160 | - throw new InvalidParameterException('Viewport must be a string of a following format: [width]x[height].'); |
|
195 | + (!is_string($params['viewport_size'] || preg_match("^\\d+x\\d+$", $params['viewport_size'])))) { |
|
196 | + throw new InvalidParameterException('Viewport must be a string of a following format: [width]x[height].'); |
|
197 | + } |
|
161 | 198 | |
162 | - if (!empty($params['id']) && !is_string($params['id'])) |
|
163 | - throw new InvalidParameterException('ID must be a string.'); |
|
199 | + if (!empty($params['id']) && !is_string($params['id'])) { |
|
200 | + throw new InvalidParameterException('ID must be a string.'); |
|
201 | + } |
|
164 | 202 | |
165 | 203 | /*if (!empty($params['file'])) |
166 | 204 | $this->validateFile($params['file']);*/ |
@@ -180,16 +218,18 @@ discard block |
||
180 | 218 | { |
181 | 219 | $filePath = substr($file, 1); |
182 | 220 | |
183 | - if (!is_file($filePath)) |
|
184 | - throw new FileNotFoundException("File ".$filePath." was not found"); |
|
221 | + if (!is_file($filePath)) { |
|
222 | + throw new FileNotFoundException("File ".$filePath." was not found"); |
|
223 | + } |
|
185 | 224 | |
186 | 225 | $path_parts = pathinfo($filePath); |
187 | 226 | |
188 | 227 | if( !in_array($path_parts['extension'], array( |
189 | 228 | "js", "css", "png", "jpg", "jpeg", "gif", "ttf", "otf", "woff" |
190 | - ))) |
|
191 | - throw new WrongFileExtensionException("Wrong file format\n |
|
229 | + ))) { |
|
230 | + throw new WrongFileExtensionException("Wrong file format\n |
|
192 | 231 | Supported formats: js, css, png, jpg, jpeg, gif, ttf, otf, woff"); |
232 | + } |
|
193 | 233 | } |
194 | 234 | |
195 | 235 | /** |
@@ -204,16 +244,18 @@ discard block |
||
204 | 244 | { |
205 | 245 | $filePath = substr($file, 1); |
206 | 246 | |
207 | - if (!is_file($filePath)) |
|
208 | - throw new FileNotFoundException("File ".$filePath." was not found"); |
|
247 | + if (!is_file($filePath)) { |
|
248 | + throw new FileNotFoundException("File ".$filePath." was not found"); |
|
249 | + } |
|
209 | 250 | |
210 | 251 | $path_parts = pathinfo($filePath); |
211 | 252 | |
212 | 253 | if( !in_array($path_parts['extension'], array( |
213 | 254 | "html", "htm", "zip", "tar.gz", "tgz", "tar.bz2" |
214 | - ))) |
|
215 | - throw new WrongFileExtensionException("Wrong file format\n |
|
255 | + ))) { |
|
256 | + throw new WrongFileExtensionException("Wrong file format\n |
|
216 | 257 | Supported formats: html, htm, zip, tar.gz, tgz, tar.bz2"); |
258 | + } |
|
217 | 259 | } |
218 | 260 | |
219 | 261 | /** |
@@ -224,29 +266,37 @@ discard block |
||
224 | 266 | */ |
225 | 267 | private function boolParams($params) |
226 | 268 | { |
227 | - if (isset($params['lowquality']) && $params['lowquality']===false) |
|
228 | - $params['lowquality'] = (int) $params['lowquality']; |
|
269 | + if (isset($params['lowquality']) && $params['lowquality']===false) { |
|
270 | + $params['lowquality'] = (int) $params['lowquality']; |
|
271 | + } |
|
229 | 272 | |
230 | - if (isset($params['images']) && $params['images']===false) |
|
231 | - $params['images'] = (int) $params['images']; |
|
273 | + if (isset($params['images']) && $params['images']===false) { |
|
274 | + $params['images'] = (int) $params['images']; |
|
275 | + } |
|
232 | 276 | |
233 | - if (isset($params['outline']) && $params['outline']===false) |
|
234 | - $params['outline'] = (int) $params['outline']; |
|
277 | + if (isset($params['outline']) && $params['outline']===false) { |
|
278 | + $params['outline'] = (int) $params['outline']; |
|
279 | + } |
|
235 | 280 | |
236 | - if (isset($params['javascript']) && $params['javascript']===false) |
|
237 | - $params['javascript'] = (int) $params['javascript']; |
|
281 | + if (isset($params['javascript']) && $params['javascript']===false) { |
|
282 | + $params['javascript'] = (int) $params['javascript']; |
|
283 | + } |
|
238 | 284 | |
239 | - if (isset($params['internal_links']) && $params['internal_links']===false) |
|
240 | - $params['internal_links'] = (int) $params['internal_links']; |
|
285 | + if (isset($params['internal_links']) && $params['internal_links']===false) { |
|
286 | + $params['internal_links'] = (int) $params['internal_links']; |
|
287 | + } |
|
241 | 288 | |
242 | - if (isset($params['external_links']) && $params['external_links']===false) |
|
243 | - $params['external_links'] = (int) $params['external_links']; |
|
289 | + if (isset($params['external_links']) && $params['external_links']===false) { |
|
290 | + $params['external_links'] = (int) $params['external_links']; |
|
291 | + } |
|
244 | 292 | |
245 | - if (isset($params['use_print_media']) && $params['use_print_media']===false) |
|
246 | - $params['use_print_media'] = (int) $params['use_print_media']; |
|
293 | + if (isset($params['use_print_media']) && $params['use_print_media']===false) { |
|
294 | + $params['use_print_media'] = (int) $params['use_print_media']; |
|
295 | + } |
|
247 | 296 | |
248 | - if (isset($params['background']) && $params['background']===false) |
|
249 | - $params['background'] = (int) $params['background']; |
|
297 | + if (isset($params['background']) && $params['background']===false) { |
|
298 | + $params['background'] = (int) $params['background']; |
|
299 | + } |
|
250 | 300 | |
251 | 301 | return $params; |
252 | 302 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | private function initiatePost($url, $params) |
44 | 44 | { |
45 | 45 | $ch = curl_init($this->host.'/'.$url); |
46 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authentication: Token ". $this->token)); |
|
46 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authentication: Token ".$this->token)); |
|
47 | 47 | curl_setopt($ch, CURLOPT_POST, 1); |
48 | 48 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
49 | 49 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | {; |
62 | 62 | if (!empty($params)) |
63 | 63 | { |
64 | - $parameter=implode(array_values($params)); |
|
64 | + $parameter = implode(array_values($params)); |
|
65 | 65 | $url .= '/'.$parameter; |
66 | 66 | } |
67 | 67 | $ch = curl_init($this->host.'/'.$url); |
68 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authentication: Token ". $this->token)); |
|
68 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authentication: Token ".$this->token)); |
|
69 | 69 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
70 | 70 | |
71 | 71 | return $ch; |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | |
84 | 84 | if (!empty($params)) |
85 | 85 | { |
86 | - $parameter=implode(array_values($params)); |
|
86 | + $parameter = implode(array_values($params)); |
|
87 | 87 | $url .= '/'.$parameter; |
88 | 88 | } |
89 | 89 | $ch = curl_init($this->host.'/'.$url); |
90 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authentication: Token ". $this->token)); |
|
90 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authentication: Token ".$this->token)); |
|
91 | 91 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
92 | 92 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); |
93 | 93 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
114 | - "Authentication: Token ". $this->token |
|
114 | + "Authentication: Token ".$this->token |
|
115 | 115 | )); |
116 | 116 | curl_setopt($ch, CURLOPT_POST, 1); |
117 | 117 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
@@ -130,26 +130,26 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function sendRequest($url, $params, $method) |
132 | 132 | { |
133 | - if($method=='POST') |
|
133 | + if ($method=='POST') |
|
134 | 134 | { |
135 | 135 | if (!empty($params['file'])) |
136 | 136 | $ch = $this->initiateUpload($url, $params); |
137 | 137 | else |
138 | 138 | $ch = $this->initiatePost($url, $params); |
139 | 139 | } |
140 | - else if($method=='GET') |
|
140 | + else if ($method=='GET') |
|
141 | 141 | { |
142 | 142 | $ch = $this->initiateGet($url, $params); |
143 | 143 | } |
144 | - else if($method=='DELETE') |
|
144 | + else if ($method=='DELETE') |
|
145 | 145 | { |
146 | 146 | $ch = $this->initiateDelete($url, $params); |
147 | 147 | } |
148 | - else{ |
|
148 | + else { |
|
149 | 149 | throw new \Exception("Method ".$method." not supported!"); |
150 | 150 | } |
151 | 151 | |
152 | - if (! $ret = curl_exec($ch)) |
|
152 | + if (!$ret = curl_exec($ch)) |
|
153 | 153 | { |
154 | 154 | trigger_error(curl_error($ch)); |
155 | 155 | } |
@@ -132,20 +132,18 @@ |
||
132 | 132 | { |
133 | 133 | if($method=='POST') |
134 | 134 | { |
135 | - if (!empty($params['file'])) |
|
136 | - $ch = $this->initiateUpload($url, $params); |
|
137 | - else |
|
138 | - $ch = $this->initiatePost($url, $params); |
|
139 | - } |
|
140 | - else if($method=='GET') |
|
135 | + if (!empty($params['file'])) { |
|
136 | + $ch = $this->initiateUpload($url, $params); |
|
137 | + } else { |
|
138 | + $ch = $this->initiatePost($url, $params); |
|
139 | + } |
|
140 | + } else if($method=='GET') |
|
141 | 141 | { |
142 | 142 | $ch = $this->initiateGet($url, $params); |
143 | - } |
|
144 | - else if($method=='DELETE') |
|
143 | + } else if($method=='DELETE') |
|
145 | 144 | { |
146 | 145 | $ch = $this->initiateDelete($url, $params); |
147 | - } |
|
148 | - else{ |
|
146 | + } else{ |
|
149 | 147 | throw new \Exception("Method ".$method." not supported!"); |
150 | 148 | } |
151 | 149 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | $this->setDescription(ServiceDescription::factory($json_location)); |
38 | 38 | |
39 | - $header = array( 'Authentication' => 'Token' . " " . $config->get('token') ); |
|
39 | + $header = array('Authentication' => 'Token'." ".$config->get('token')); |
|
40 | 40 | $this->setDefaultOption("headers", $header); |
41 | 41 | } |
42 | 42 | |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function sendRequest($url, $params, $method) |
53 | 53 | { |
54 | - try{ |
|
55 | - if (!empty($params['html'])){ |
|
54 | + try { |
|
55 | + if (!empty($params['html'])) { |
|
56 | 56 | $commandName = 'GenerateFromHTML'; |
57 | 57 | } |
58 | - else if (!empty($params['url'])){ |
|
58 | + else if (!empty($params['url'])) { |
|
59 | 59 | $commandName = 'GenerateFromURL'; |
60 | 60 | } |
61 | - else if (!empty($params['file'])&& $url=='pdf'){ |
|
61 | + else if (!empty($params['file']) && $url=='pdf') { |
|
62 | 62 | $commandName = 'GenerateFromFile'; |
63 | 63 | } |
64 | 64 | else { |
65 | 65 | $operations = $this->getDescription()->getOperations(); |
66 | 66 | foreach ($operations as $operation) |
67 | 67 | { |
68 | - if ($operation->getUri()==$url && $operation->getHttpMethod() == $method) |
|
68 | + if ($operation->getUri()==$url && $operation->getHttpMethod()==$method) |
|
69 | 69 | { |
70 | 70 | $commandName = $operation->getName(); |
71 | 71 | } |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | $command = $this->getCommand($commandName, $params); |
75 | 75 | $ret = $this->execute($command); |
76 | 76 | |
77 | - if ( $commandName == 'GetAssetList' || $commandName == 'UploadAsset' ) |
|
77 | + if ($commandName=='GetAssetList' || $commandName=='UploadAsset') |
|
78 | 78 | { |
79 | 79 | return json_encode($ret); |
80 | 80 | } |
81 | 81 | return $ret->getBody(true); |
82 | 82 | |
83 | - }catch(ClientErrorResponseException $exception){ |
|
83 | + } catch (ClientErrorResponseException $exception) { |
|
84 | 84 | throw new \Exception($exception->getResponse()->getBody(true), $exception->getResponse()->getStatusCode()); |
85 | 85 | } |
86 | 86 | } |
@@ -54,14 +54,11 @@ discard block |
||
54 | 54 | try{ |
55 | 55 | if (!empty($params['html'])){ |
56 | 56 | $commandName = 'GenerateFromHTML'; |
57 | - } |
|
58 | - else if (!empty($params['url'])){ |
|
57 | + } else if (!empty($params['url'])){ |
|
59 | 58 | $commandName = 'GenerateFromURL'; |
60 | - } |
|
61 | - else if (!empty($params['file'])&& $url=='pdf'){ |
|
59 | + } else if (!empty($params['file'])&& $url=='pdf'){ |
|
62 | 60 | $commandName = 'GenerateFromFile'; |
63 | - } |
|
64 | - else { |
|
61 | + } else { |
|
65 | 62 | $operations = $this->getDescription()->getOperations(); |
66 | 63 | foreach ($operations as $operation) |
67 | 64 | { |
@@ -80,7 +77,7 @@ discard block |
||
80 | 77 | } |
81 | 78 | return $ret->getBody(true); |
82 | 79 | |
83 | - }catch(ClientErrorResponseException $exception){ |
|
80 | + } catch(ClientErrorResponseException $exception){ |
|
84 | 81 | throw new \Exception($exception->getResponse()->getBody(true), $exception->getResponse()->getStatusCode()); |
85 | 82 | } |
86 | 83 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function generateFromURL($params) |
41 | 41 | { |
42 | - if(empty($params['url'])) |
|
43 | - throw new \Exception('Parameter \'url\' must be set' ); |
|
42 | + if (empty($params['url'])) |
|
43 | + throw new \Exception('Parameter \'url\' must be set'); |
|
44 | 44 | |
45 | 45 | $params = $this->validator->validate($params); |
46 | 46 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function generateFromHTML($params) |
63 | 63 | { |
64 | - if(empty($params['html'])) |
|
65 | - throw new \Exception('Parameter \'html\' must be set' ); |
|
64 | + if (empty($params['html'])) |
|
65 | + throw new \Exception('Parameter \'html\' must be set'); |
|
66 | 66 | |
67 | 67 | $params = $this->validator->validate($params); |
68 | 68 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function generateFromFile($params) |
84 | 84 | { |
85 | - if(empty($params['file'])) |
|
86 | - throw new \Exception('Parameter \'file\' must be set' ); |
|
85 | + if (empty($params['file'])) |
|
86 | + throw new \Exception('Parameter \'file\' must be set'); |
|
87 | 87 | |
88 | 88 | $params['file'] = '@'.$params['file']; |
89 | 89 | $params = $this->validator->validate($params); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function uploadAsset($filePath) |
124 | 124 | { |
125 | - $params = array( 'file' => '@'.$filePath ); |
|
125 | + $params = array('file' => '@'.$filePath); |
|
126 | 126 | $params = $this->validator->validate($params); |
127 | 127 | $this->validator->validateAssetFile($params['file']); |
128 | 128 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function getAsset($id) |
144 | 144 | { |
145 | - $params = array( 'id' => $id ); |
|
145 | + $params = array('id' => $id); |
|
146 | 146 | $params = $this->validator->validate($params); |
147 | 147 | |
148 | 148 | try { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function deleteAsset($id) |
163 | 163 | { |
164 | - $params = array( 'id' => $id ); |
|
164 | + $params = array('id' => $id); |
|
165 | 165 | $params = $this->validator->validate($params); |
166 | 166 | |
167 | 167 | try { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | foreach ($list_json as $asset) |
205 | 205 | { |
206 | - if ($asset['name'] == $name) |
|
206 | + if ($asset['name']==$name) |
|
207 | 207 | { |
208 | 208 | return $asset['id']; |
209 | 209 | } |
@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function generateFromURL($params) |
41 | 41 | { |
42 | - if(empty($params['url'])) |
|
43 | - throw new \Exception('Parameter \'url\' must be set' ); |
|
42 | + if(empty($params['url'])) { |
|
43 | + throw new \Exception('Parameter \'url\' must be set' ); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | $params = $this->validator->validate($params); |
46 | 47 | |
@@ -61,8 +62,9 @@ discard block |
||
61 | 62 | */ |
62 | 63 | public function generateFromHTML($params) |
63 | 64 | { |
64 | - if(empty($params['html'])) |
|
65 | - throw new \Exception('Parameter \'html\' must be set' ); |
|
65 | + if(empty($params['html'])) { |
|
66 | + throw new \Exception('Parameter \'html\' must be set' ); |
|
67 | + } |
|
66 | 68 | |
67 | 69 | $params = $this->validator->validate($params); |
68 | 70 | |
@@ -82,8 +84,9 @@ discard block |
||
82 | 84 | */ |
83 | 85 | public function generateFromFile($params) |
84 | 86 | { |
85 | - if(empty($params['file'])) |
|
86 | - throw new \Exception('Parameter \'file\' must be set' ); |
|
87 | + if(empty($params['file'])) { |
|
88 | + throw new \Exception('Parameter \'file\' must be set' ); |
|
89 | + } |
|
87 | 90 | |
88 | 91 | $params['file'] = '@'.$params['file']; |
89 | 92 | $params = $this->validator->validate($params); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * |
12 | 12 | * @param string $message Message of the exception |
13 | 13 | */ |
14 | - public function __construct ($message) |
|
14 | + public function __construct($message) |
|
15 | 15 | { |
16 | 16 | parent::__construct($message); |
17 | 17 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * |
12 | 12 | * @param string $message Message of the exception |
13 | 13 | */ |
14 | - public function __construct ($message) |
|
14 | + public function __construct($message) |
|
15 | 15 | { |
16 | 16 | parent::__construct($message); |
17 | 17 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | * |
12 | 12 | * @param string $message Message of the exception |
13 | 13 | */ |
14 | - public function __construct ($message) |
|
14 | + public function __construct($message) |
|
15 | 15 | { |
16 | 16 | parent::__construct($message); |
17 | 17 | } |