Skip to content

Commit feedb10

Browse files
author
klapaudius
committed
Simplify conditional checks in MakeMcpToolCommand.
Combine nested conditions into single statements to improve readability and reduce code duplication. This change ensures the logic remains clean and easier to maintain.
1 parent 04dc5ba commit feedb10

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/Command/MakeMcpToolCommand.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,15 @@ protected function detectYamlIndentation(string $content): int
190190
$indentation = null;
191191

192192
// Look for the first tool entry to determine indentation
193-
if (preg_match('/tools:.*\n(\s+)-\s/s', $content, $matches)) {
194-
if (isset($matches[1])) {
195-
// Count the number of spaces before the first tool entry
196-
$indentation = strlen($matches[1]);
197-
}
193+
if (preg_match('/tools:.*\n(\s+)-\s/s', $content, $matches)
194+
&& isset($matches[1])) {
195+
// Count the number of spaces before the first tool entry
196+
$indentation = strlen($matches[1]);
198197
}
199-
if (! $indentation && preg_match('/([[:blank:]]+)tools:.*\[\]/s', $content, $matches)) {
200-
if (isset($matches[1])) {
201-
$indentation = strlen($matches[1])*2;
202-
}
198+
if (! $indentation
199+
&& preg_match('/([[:blank:]]+)tools:/s', $content, $matches)
200+
&& isset($matches[1])) {
201+
$indentation = strlen($matches[1])*2;
203202
}
204203

205204
return $indentation ?? 8;

0 commit comments

Comments
 (0)