Test Failed
Push — master ( a6b51e...5fffdb )
by Gabriel
08:05
created

Client::initIdentifierFromDb()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 2
1
<?php
2
3
namespace ByTIC\Hello\Models\Clients;
4
5
use ByTIC\Hello\Utility\RandomHelper;
6
use League\OAuth2\Server\Entities\ClientEntityInterface;
7
use League\OAuth2\Server\Entities\Traits\ClientTrait;
8
use League\OAuth2\Server\Entities\Traits\EntityTrait;
9
10
/**
11
 * Class Token
12
 * @package ByTIC\Hello\Models\Clients
13
 */
14
class Client extends \Nip\Records\Record implements ClientEntityInterface
15
{
16
    use ClientTrait, EntityTrait;
17
    use Traits\ClientHasGrantsTrait;
18
    use Traits\ClientHasSecretTrait;
19
    use Traits\ClientHasRedirectTrait;
20
21 19
    public function __construct()
22
    {
23 19
        $this->setIdentifier(RandomHelper::generateIdentifier());
24 19
        $this->setSecret(RandomHelper::generateToken());
25 19
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30 10
    public function writeData($data = false)
31
    {
32 10
        parent::writeData($data);
33 10
        $this->initGrantsFromDb();
34 10
        $this->initIdentifierFromDb();
35 10
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40 19
    public function setIdentifier($value)
41
    {
42 19
        $this->_data['identifier'] = $value;
43 19
        $this->identifier = $value;
44 19
    }
45
46 10
    public function initIdentifierFromDb()
47
    {
48 10
        if (!empty($this->_data['identifier'])) {
49 10
            $this->setIdentifier($this->_data['identifier']);
50
        }
51 10
    }
52
53
    /**
54
     * @param mixed $name
55
     */
56 4
    public function setName($name)
57
    {
58 4
        $this->name = $name;
59 4
        parent::setName($name);
60 4
    }
61
}
62