Skip to content

Commit 726b5d6

Browse files
committed
Tiny refactoring
1 parent 8602d6c commit 726b5d6

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Sentry/Laravel/EventHandler.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use Sentry\SentrySdk;
2929
use Sentry\State\Scope;
3030
use Symfony\Component\Console\Input\ArgvInput;
31-
use Symfony\Component\Console\Input\ArrayInput;
3231
use Symfony\Component\Console\Input\InputInterface;
3332

3433
class EventHandler
@@ -572,7 +571,7 @@ protected function commandStartingHandler(CommandStarting $event)
572571
'artisan.command',
573572
'Starting Artisan command: ' . $event->command,
574573
[
575-
'input' => $this->extractCommandInput($event->input),
574+
'input' => $this->extractConsoleCommandInput($event->input),
576575
]
577576
));
578577
}
@@ -593,21 +592,27 @@ protected function commandFinishedHandler(CommandFinished $event)
593592
'Finished Artisan command: ' . $event->command,
594593
[
595594
'exit' => $event->exitCode,
596-
'input' => $this->extractCommandInput($event->input),
595+
'input' => $this->extractConsoleCommandInput($event->input),
597596
]
598597
));
599598
}
600599

601-
Integration::configureScope(static function (Scope $scope): void {
602-
$scope->setTag('command', '');
603-
});
604-
605600
// Flush any and all events that were possibly generated by the command
606601
Integration::flushEvents();
602+
603+
Integration::configureScope(static function (Scope $scope): void {
604+
$scope->removeTag('command');
605+
});
607606
}
608607

609-
/** @return string|null */
610-
private function extractCommandInput(InputInterface $input)
608+
/**
609+
* Extract the command input arguments if possible.
610+
*
611+
* @param \Symfony\Component\Console\Input\InputInterface|null $input
612+
*
613+
* @return string|null
614+
*/
615+
private function extractConsoleCommandInput(?InputInterface $input): ?string
611616
{
612617
if ($input instanceof ArgvInput) {
613618
return (string)$input;

0 commit comments

Comments
 (0)