Skip to content

Commit 26386d6

Browse files
committed
📦 Ensure retrieved data from event. Drop unused variable. Check controller only for null value
1 parent 7b77d95 commit 26386d6

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/Name/Generator/CommandNameGenerator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ public static function getSubscribedEvents(): array
3636

3737
public function onCommand(ConsoleCommandEvent $event): void
3838
{
39-
if (null === $event->getCommand()) {
39+
if (null === $command = $event->getCommand()) {
4040
return;
4141
}
42-
$this->name = (string)$event->getCommand()->getName();
42+
43+
$this->name = (string)$command->getName();
4344
}
4445

4546
public function onTerminate(): CommandNameGenerator

src/Name/Generator/DefaultNameGenerator.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,24 @@ public static function getSubscribedEvents(): array
2626

2727
public function onCommand(ConsoleCommandEvent $event): void
2828
{
29-
if (null === $event->getCommand()) {
29+
if (null === $command = $event->getCommand()) {
3030
return;
3131
}
3232

33-
$this->name = (string)$event->getCommand()->getName();
33+
$this->name = (string)$command->getName();
3434
}
3535

3636
public function onRequest(RequestEvent $event): void
3737
{
3838
$request = $event->getRequest();
39-
if (null !== ($fragment = $request->attributes->get('is_fragment'))) {
40-
$this->name = ($controller = $request->attributes->get('_controller', null))
39+
if (null !== $request->attributes->get('is_fragment')) {
40+
$this->name = (null !== $controller = $request->attributes->get('_controller', null))
4141
? sprintf('fragment.%s', $controller)
4242
: 'fragment';
43+
4344
return;
4445
}
46+
4547
$this->name = $request->attributes->get('_route', $request->getRequestUri());
4648
}
4749

0 commit comments

Comments
 (0)