Passed
Push — master ( 8de9f1...2c24c4 )
by Artem
01:57
created

TrustedDeviceRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 27
ccs 15
cts 15
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonToEntity() 0 3 1
A getSupportedFields() 0 9 1
A getBaseUri() 0 3 1
A revoke() 0 3 1
1
<?php
2
3
// ---------------------------------------------------------------------
4
//
5
//  Copyright (C) 2018-2024 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <http://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\Internal\Profile;
13
14
use Linode\Entity\Entity;
15
use Linode\Entity\Profile\TrustedDevice;
16
use Linode\Internal\AbstractRepository;
17
use Linode\Repository\Profile\TrustedDeviceRepositoryInterface;
18
19
class TrustedDeviceRepository extends AbstractRepository implements TrustedDeviceRepositoryInterface
20
{
21 1
    public function revoke(int $id): void
22
    {
23 1
        $this->client->api($this->client::REQUEST_DELETE, sprintf('%s/%s', $this->getBaseUri(), $id));
24
    }
25
26 2
    protected function getBaseUri(): string
27
    {
28 2
        return '/profile/devices';
29
    }
30
31 1
    protected function getSupportedFields(): array
32
    {
33 1
        return [
34 1
            TrustedDevice::FIELD_ID,
35 1
            TrustedDevice::FIELD_CREATED,
36 1
            TrustedDevice::FIELD_EXPIRY,
37 1
            TrustedDevice::FIELD_USER_AGENT,
38 1
            TrustedDevice::FIELD_LAST_AUTHENTICATED,
39 1
            TrustedDevice::FIELD_LAST_REMOTE_ADDR,
40 1
        ];
41
    }
42
43 1
    protected function jsonToEntity(array $json): Entity
44
    {
45 1
        return new TrustedDevice($this->client, $json);
46
    }
47
}
48