ClientService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 36
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generateSecret() 0 8 1
A getClientRepository() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace OAuth\Service;
4
5
use OAuth\Client;
6
use OAuth\Repository\ClientRepository;
7
8
/**
9
 * Class ClientService
10
 * @package Entity\OAuth\Service
11
 */
12
class ClientService
13
{
14
    /**
15
     * @var ClientRepository
16
     */
17
    private $clientRepository;
18
19
    /**
20
     * ClientService constructor.
21
     * @param ClientRepository $clientRepository
22
     */
23
    public function __construct(ClientRepository $clientRepository)
24
    {
25
        $this->clientRepository = $clientRepository;
26
    }
27
28
    /**
29
     * @return ClientRepository
30
     */
31
    public function getClientRepository(): ClientRepository
32
    {
33
        return $this->clientRepository;
34
    }
35
36
    /**
37
     * @param Client $client
38
     * @return Client
39
     */
40
    public function generateSecret(Client $client)
41
    {
42
        $time = microtime();
43
        $name = $client->getName();
44
        $secret = password_hash($name . $time  . 'bone', PASSWORD_BCRYPT);
45
        $base64 = base64_encode($secret);
46
        $client->setSecret($base64);
47
        return $client;
48
    }
49
}