EventRepository   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 20
c 0
b 0
f 0
dl 0
loc 40
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseUri() 0 3 1
A eventSeen() 0 3 1
A eventRead() 0 3 1
A jsonToEntity() 0 3 1
A getSupportedFields() 0 17 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 <https://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\Account\Repository;
13
14
use Linode\Account\Event;
15
use Linode\Account\EventRepositoryInterface;
16
use Linode\Entity;
17
use Linode\Internal\AbstractRepository;
18
19
/**
20
 * @codeCoverageIgnore This class was autogenerated.
21
 */
22
class EventRepository extends AbstractRepository implements EventRepositoryInterface
23
{
24
    public function eventRead(int $eventId): void
25
    {
26
        $this->client->post(sprintf('%s/%s/read', $this->getBaseUri(), $eventId));
27
    }
28
29
    public function eventSeen(int $eventId): void
30
    {
31
        $this->client->post(sprintf('%s/%s/seen', $this->getBaseUri(), $eventId));
32
    }
33
34
    protected function getBaseUri(): string
35
    {
36
        return '/account/events';
37
    }
38
39
    protected function getSupportedFields(): array
40
    {
41
        return [
42
            Event::FIELD_ID,
43
            Event::FIELD_USERNAME,
44
            Event::FIELD_ACTION,
45
            Event::FIELD_ENTITY,
46
            Event::FIELD_SECONDARY_ENTITY,
47
            Event::FIELD_CREATED,
48
            Event::FIELD_DURATION,
49
            Event::FIELD_PERCENT_COMPLETE,
50
            Event::FIELD_RATE,
51
            Event::FIELD_READ,
52
            Event::FIELD_SEEN,
53
            Event::FIELD_STATUS,
54
            Event::FIELD_TIME_REMAINING,
55
            Event::FIELD_MESSAGE,
56
        ];
57
    }
58
59
    protected function jsonToEntity(array $json): Entity
60
    {
61
        return new Event($this->client, $json);
62
    }
63
}
64