SendEmailAboutUserLoginEventSubscriber   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 4 1
A sendEmail() 0 6 1
1
<?php
2
3
namespace MyApp\EventSubscriber;
4
5
use MyApp\Event\AppEvents;
6
use MyApp\Event\UserLoginEvent;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
10
final class SendEmailAboutUserLoginEventSubscriber implements EventSubscriberInterface
11
{
12
13
	/**
14
	 * {@inheritdoc}
15
	 */
16
	public static function getSubscribedEvents()
17
	{
18
		return [AppEvents::ON_LOGIN => 'sendEmail'];
19
	}
20
21
22
	public function sendEmail(UserLoginEvent $userLoginEvent)
23
	{
24
		$userName = $userLoginEvent->getName();
0 ignored issues
show
Unused Code introduced by
$userName is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
		// send a notification email that `$userName` just logged in
26
		// ...
27
	}
28
29
}
30