Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.

Commit 7cdc02e

Browse files
committed
Improved arguments string generation
1 parent 5a206e8 commit 7cdc02e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/WiremockArguments.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,24 @@ public function generateArgumentsString(array $config)
4040

4141
foreach ($config as $key => $value) {
4242
if (isset($this->map[$key])) {
43-
$result .= " --{$key}" . ($this->map[$key]? " $value" : '');
43+
$result .= $this->evaluateValueConfig($key, $this->map[$key], $value);
4444
}
4545
}
4646

4747
return $result;
4848
}
4949

50+
private function evaluateValueConfig($key, $withValue, $value)
51+
{
52+
if ($withValue) {
53+
return " --{$key} {$value}";
54+
}
55+
if ($value) {
56+
return " --{$key}";
57+
}
58+
return '';
59+
}
60+
5061
public function sanitize(array $config)
5162
{
5263
$return = array_merge($this->defaults, $config);

0 commit comments

Comments
 (0)