Passed
Pull Request — master (#1074)
by Andrew
02:07
created

DeviceCodeRepository::revokeDeviceCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * @author    Andrew Millington <[email protected]>
4
 * @copyright Copyright (c) Alex Bilbie
5
 * @license   http://mit-license.org/
6
 *
7
 * @link      https://github.com/thephpleague/oauth2-server
8
 */
9
10
namespace OAuth2ServerExamples\Repositories;
11
12
use League\OAuth2\Server\Entities\ClientEntityInterface;
13
use League\OAuth2\Server\Entities\DeviceCodeEntityInterface;
14
use League\OAuth2\Server\Repositories\DeviceCodeRepositoryInterface;
15
use OAuth2ServerExamples\Entities\DeviceCodeEntity;
16
17
class DeviceCodeRepository implements DeviceCodeRepositoryInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function getNewDeviceCode()
23
    {
24
        return new DeviceCodeEntity();
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function persistNewDeviceCode(DeviceCodeEntityInterface $deviceCodeEntity)
31
    {
32
        // Some logic to persist a new device code to a database
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getDeviceCodeEntityByDeviceCode($deviceCode, $grantType, ClientEntityInterface $clientEntity)
39
    {
40
        $deviceCode = new DeviceCodeEntity();
41
42
        // The user identifier should be set when the user authenticates on the OAuth server
43
        $deviceCode->setUserIdentifier(1);
44
45
        return $deviceCode;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function revokeDeviceCode($codeId)
52
    {
53
        // Some logic to revoke device code
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function isDeviceCodeRevoked($codeId)
60
    {
61
        // Some logic to check if a device code has been revoked
62
    }
63
}
64