File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 7
7
8
8
### Fixed
9
9
10
+ ## [ 2.0.2] - 2016-09-20
11
+ ### Fixed
12
+ - Fixed a bug with options without values
13
+
10
14
## [ 2.0.1] - 2016-05-19
11
15
### Fixed
12
16
- Fixed a critical bug
Original file line number Diff line number Diff line change @@ -50,8 +50,11 @@ $input->setUrl('https://www.google.com');
50
50
51
51
$converter = new Converter($input, new DownloadOutput());
52
52
53
+ $converter->setOption('n');
53
54
$converter->setOption('d', '300');
55
+
54
56
$converter->setOptions([
57
+ 'no-background',
55
58
'margin-bottom' => '100',
56
59
'margin-top' => '100',
57
60
]);
Original file line number Diff line number Diff line change @@ -152,6 +152,13 @@ public function setOptions($options)
152
152
}
153
153
154
154
foreach ($ options as $ key => $ value ) {
155
+
156
+ // Convert key-only options to regular ones
157
+ if (is_numeric ($ key ) && !empty ($ value )) {
158
+ $ key = $ value ;
159
+ $ value = '' ;
160
+ }
161
+
155
162
$ this ->setOption ($ key , $ value );
156
163
}
157
164
@@ -225,9 +232,9 @@ private function buildCommand()
225
232
}
226
233
227
234
$ key = escapeshellcmd (trim ($ key ));
228
- $ value = escapeshellarg ( trim ($ value) );
235
+ $ value = trim ($ value );
229
236
230
- $ optionsString .= $ key . ' ' . $ value . ' ' ;
237
+ $ optionsString .= $ key . ( empty ( $ value ) ? '' : ' ' . escapeshellarg ( $ value)) . ' ' ;
231
238
}
232
239
233
240
$ command = $ this ->getBinaryPath () . ' ' . $ optionsString . ' - - ' ;
Original file line number Diff line number Diff line change @@ -25,14 +25,19 @@ public function setUp()
25
25
26
26
public function testOptions ()
27
27
{
28
+ $ this ->converter ->setOption ('n ' );
28
29
$ this ->converter ->setOption ('R ' , '500 ' );
29
30
$ this ->converter ->setOption ('margin-top ' , '100 ' );
30
31
31
32
$ this ->converter ->setOptions ([
33
+ 'ignore-load-errors ' ,
32
34
'B ' => '50 ' ,
33
35
'margin-left ' => '10 ' ,
34
36
]);
35
37
38
+ $ value = $ this ->converter ->getOption ('n ' );
39
+ $ this ->assertEquals ('' , $ value );
40
+
36
41
$ value = $ this ->converter ->getOption ('R ' );
37
42
$ this ->assertEquals ('500 ' , $ value );
38
43
@@ -41,8 +46,10 @@ public function testOptions()
41
46
42
47
$ options = $ this ->converter ->getOptions ();
43
48
$ this ->assertEquals ([
49
+ 'n ' => '' ,
44
50
'R ' => '500 ' ,
45
51
'margin-top ' => '100 ' ,
52
+ 'ignore-load-errors ' => '' ,
46
53
'B ' => '50 ' ,
47
54
'margin-left ' => '10 ' ,
48
55
], $ options );
You can’t perform that action at this time.
0 commit comments