Skip to content

Commit e15d0d3

Browse files
Refactor
1 parent f9fb465 commit e15d0d3

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/Util/PHP/JobRunner.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use function array_merge;
1616
use function array_values;
1717
use function assert;
18+
use function count;
19+
use function explode;
1820
use function fclose;
1921
use function file_get_contents;
2022
use function file_put_contents;
@@ -30,8 +32,6 @@
3032
use function str_replace;
3133
use function str_starts_with;
3234
use function stream_get_contents;
33-
use function strpos;
34-
use function substr;
3535
use function sys_get_temp_dir;
3636
use function tempnam;
3737
use function trim;
@@ -347,20 +347,18 @@ private function settingsToParameters(array $settings): array
347347
*/
348348
private function quoteSettingValue(string $setting): string
349349
{
350-
$position = strpos($setting, '=');
350+
$parts = explode('=', $setting, 2);
351351

352-
if ($position === false) {
352+
if (count($parts) !== 2) {
353353
return $setting;
354354
}
355355

356-
$value = substr($setting, $position + 1);
356+
[$name, $value] = $parts;
357357

358358
if (!str_contains($value, ';') && !str_contains($value, '"')) {
359359
return $setting;
360360
}
361361

362-
$name = substr($setting, 0, $position);
363-
364362
return $name . '="' . str_replace('"', '\\"', $value) . '"';
365363
}
366364
}

0 commit comments

Comments
 (0)