LastLoginProcessor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A process() 0 9 2
1
<?php
2
3
namespace Smart\AuthenticationBundle\Security\Processor;
4
5
use DateTime;
6
use Doctrine\ORM\EntityManager;
7
use Smart\AuthenticationBundle\Security\LastLoginInterface;
8
9
/**
10
 * @author Mathieu Ducrot <[email protected]>
11
 */
12
class LastLoginProcessor
13
{
14
    /**
15
     * @var EntityManager
16
     */
17
    private $em;
18
19
    /**
20
     * @param EntityManager $em
21
     */
22
    public function __construct(EntityManager $em)
23
    {
24
        $this->em = $em;
25
    }
26
27
    /**
28
     * @param LastLoginInterface $object
29
     *
30
     * @return void
31
     */
32
    public function process($object)
33
    {
34
        if (!$object instanceof LastLoginInterface) {
0 ignored issues
show
introduced by
$object is always a sub-type of Smart\AuthenticationBund...rity\LastLoginInterface.
Loading history...
35
            return;
36
        }
37
38
        $object->setLastLogin(new DateTime());
39
        $this->em->persist($object);
40
        $this->em->flush();
41
    }
42
}
43