Skip to content

Commit 4cdf870

Browse files
authored
simplify debugResponse logic (#38)
1 parent adb0d9e commit 4cdf870

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/Codeception/Module/Symfony.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -624,38 +624,38 @@ protected function debugResponse($url)
624624
{
625625
parent::debugResponse($url);
626626

627-
if ($profile = $this->getProfile()) {
628-
if ($profile->hasCollector('security')) {
629-
if ($profile->getCollector('security')->isAuthenticated()) {
630-
$roles = $profile->getCollector('security')->getRoles();
631-
632-
if ($roles instanceof Data) {
633-
$roles = $this->extractRawRoles($roles);
634-
}
635-
636-
$this->debugSection(
637-
'User',
638-
$profile->getCollector('security')->getUser()
639-
. ' [' . implode(',', $roles) . ']'
640-
);
641-
} else {
642-
$this->debugSection('User', 'Anonymous');
643-
}
644-
}
645-
if ($profile->hasCollector('swiftmailer')) {
646-
$messages = $profile->getCollector('swiftmailer')->getMessageCount();
647-
if ($messages) {
648-
$this->debugSection('Emails', $messages . ' sent');
649-
}
650-
} elseif ($profile->hasCollector('mailer')) {
651-
$messages = count($profile->getCollector('mailer')->getEvents()->getMessages());
652-
if ($messages) {
653-
$this->debugSection('Emails', $messages . ' sent');
627+
if (!$profile = $this->getProfile()) {
628+
return;
629+
}
630+
631+
if ($profile->hasCollector('security')) {
632+
$security = $profile->getCollector('security');
633+
if ($security->isAuthenticated()) {
634+
$roles = $security->getRoles();
635+
636+
if ($roles instanceof Data) {
637+
$roles = $this->extractRawRoles($roles);
654638
}
639+
640+
$this->debugSection(
641+
'User',
642+
$security->getUser()
643+
. ' [' . implode(',', $roles) . ']'
644+
);
645+
} else {
646+
$this->debugSection('User', 'Anonymous');
655647
}
656-
if ($profile->hasCollector('timer')) {
657-
$this->debugSection('Time', $profile->getCollector('timer')->getTime());
658-
}
648+
}
649+
if ($profile->hasCollector('swiftmailer')) {
650+
$emails = $profile->getCollector('swiftmailer')->getMessageCount();
651+
} elseif ($profile->hasCollector('mailer')) {
652+
$emails = count($profile->getCollector('mailer')->getEvents()->getMessages());
653+
}
654+
if (isset($emails)) {
655+
$this->debugSection('Emails', $emails . ' sent');
656+
}
657+
if ($profile->hasCollector('timer')) {
658+
$this->debugSection('Time', $profile->getCollector('timer')->getTime());
659659
}
660660
}
661661

0 commit comments

Comments
 (0)