ClientService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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
}