Ui   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 56
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getNavigation() 0 6 1
A createCustomButton() 0 15 2
A getCustomButton() 0 6 1
A deleteCustomButton() 0 4 1
1
<?php
2
// Copyright 1999-2021. Plesk International GmbH.
3
4
namespace PleskX\Api\Operator;
5
6
use PleskX\Api\Struct\Ui as Struct;
7
8
class Ui extends \PleskX\Api\Operator
9
{
10
    /**
11
     * @return array
12
     */
13
    public function getNavigation()
14
    {
15
        $response = $this->request('get-navigation');
16
17
        return unserialize(base64_decode($response->navigation));
18
    }
19
20
    /**
21
     * @param string $owner
22
     * @param array $properties
23
     *
24
     * @return int
25
     */
26
    public function createCustomButton($owner, $properties)
27
    {
28
        $packet = $this->_client->getPacket();
29
        $buttonNode = $packet->addChild($this->_wrapperTag)->addChild('create-custombutton');
30
        $buttonNode->addChild('owner')->addChild($owner);
31
        $propertiesNode = $buttonNode->addChild('properties');
32
33
        foreach ($properties as $name => $value) {
34
            $propertiesNode->addChild($name, $value);
35
        }
36
37
        $response = $this->_client->request($packet);
38
39
        return (int) $response->id;
40
    }
41
42
    /**
43
     * @param int $id
44
     *
45
     * @return Struct\CustomButton
46
     */
47
    public function getCustomButton($id)
48
    {
49
        $response = $this->request("get-custombutton.filter.custombutton-id=$id");
50
51
        return new Struct\CustomButton($response);
52
    }
53
54
    /**
55
     * @param int $id
56
     *
57
     * @return bool
58
     */
59
    public function deleteCustomButton($id)
60
    {
61
        return $this->_delete('custombutton-id', $id, 'delete-custombutton');
62
    }
63
}
64