Completed
Push — master ( 6a0ab6...96f47f )
by Mārtiņš
02:11
created

Search::retrieveIdenityByToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 9.6666
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Palladium\Service;
4
5
6
/**
7
 * Class for finding indentities based on various conditions
8
 */
9
10
use Palladium\Mapper as Mapper;
11
use Palladium\Entity as Entity;
12
use Palladium\Exception\UserNotFound;
13
use Palladium\Exception\IdentityNotFound;
14
use Palladium\Exception\TokenNotFound;
15
16
use Palladium\Contract\CanCreateMapper;
17
use Psr\Log\LoggerInterface;
18
19
20
class Search
21
{
22
23
    private $mapperFactory;
24
    private $logger;
25
26
27
    public function __construct(CanCreateMapper $mapperFactory, LoggerInterface $logger)
28
    {
29
        $this->mapperFactory = $mapperFactory;
30
        $this->logger = $logger;
31
    }
32
33
34
    public function retrieveIdenityByToken(Entity\Identity $identity)
35
    {
36
        $identity->setTokenEndOfLife(time());
37
38
        $mapper = $this->mapperFactory->create(Mapper\Identity::class);
39
        $mapper->fetch($identity);
40
41
        return $identity;
42
    }
43
}
44