Passed
Push — master ( 8232a2...33e29c )
by Dev
13:28
created

UserListener::preUpdate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
c 1
b 0
f 1
nc 2
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
namespace PiedWeb\CMSBundle\EventListener;
4
5
use PiedWeb\CMSBundle\Entity\UserInterface;
6
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoder;
7
use Doctrine\ORM\Event\PreUpdateEventArgs;
8
9
class UserListener
10
{
11
12
    protected $passwordEncoder;
13
14
    public function __construct(UserPasswordEncoder $passwordEncoder) {
15
        $this->passwordEncoder = $passwordEncoder;
16
    }
17
18
    public function preUpdate(UserInterface $user, PreUpdateEventArgs $event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

18
    public function preUpdate(UserInterface $user, /** @scrutinizer ignore-unused */ PreUpdateEventArgs $event)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20
        if (strlen($user->getPlainPassword()) > 0) {
21
            $user->setPassword($this->passwordEncoder->encodePassword($user, $user->getPlainPassword()));
22
            $user->eraseCredentials();
23
        }
24
    }
25
}
26