Passed
Push — master ( 0676a7...01ab94 )
by Artem
11:54
created

ManagedLinodeSettingsRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 12
dl 0
loc 29
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A updateManagedLinodeSetting() 0 7 1
A getSupportedFields() 0 7 1
A jsonToEntity() 0 3 1
A getBaseUri() 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 <https://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\Managed\Repository;
13
14
use Linode\Entity;
15
use Linode\Internal\AbstractRepository;
16
use Linode\Managed\ManagedLinodeSettings;
17
use Linode\Managed\ManagedLinodeSettingsRepositoryInterface;
18
19
/**
20
 * @codeCoverageIgnore This class was autogenerated.
21
 */
22
class ManagedLinodeSettingsRepository extends AbstractRepository implements ManagedLinodeSettingsRepositoryInterface
23
{
24
    public function updateManagedLinodeSetting(int $linodeId, array $parameters = []): ManagedLinodeSettings
25
    {
26
        $response = $this->client->put(sprintf('%s/%s', $this->getBaseUri(), $linodeId), $parameters);
27
        $contents = $response->getBody()->getContents();
28
        $json     = json_decode($contents, true);
29
30
        return new ManagedLinodeSettings($this->client, $json);
31
    }
32
33
    protected function getBaseUri(): string
34
    {
35
        return '/managed/linode-settings';
36
    }
37
38
    protected function getSupportedFields(): array
39
    {
40
        return [
41
            ManagedLinodeSettings::FIELD_ID,
42
            ManagedLinodeSettings::FIELD_LABEL,
43
            ManagedLinodeSettings::FIELD_GROUP,
44
            ManagedLinodeSettings::FIELD_SSH,
45
        ];
46
    }
47
48
    protected function jsonToEntity(array $json): Entity
49
    {
50
        return new ManagedLinodeSettings($this->client, $json);
51
    }
52
}
53