Completed
Push — master ( 930490...fc561b )
by
unknown
23s queued 11s
created

Webspace::getLimits()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
// Copyright 1999-2019. Plesk International GmbH.
3
4
namespace PleskX\Api\Operator;
5
use PleskX\Api\Struct\Webspace as Struct;
6
7
class Webspace extends \PleskX\Api\Operator
8
{
9
10
    public function getPermissionDescriptor()
11
    {
12
        $response = $this->request('get-permission-descriptor.filter');
13
        return new Struct\PermissionDescriptor($response);
14
    }
15
16
    public function getLimitDescriptor()
17
    {
18
        $response = $this->request('get-limit-descriptor.filter');
19
        return new Struct\LimitDescriptor($response);
20
    }
21
22
    public function getPhysicalHostingDescriptor()
23
    {
24
        $response = $this->request('get-physical-hosting-descriptor.filter');
25
        return new Struct\PhysicalHostingDescriptor($response);
26
    }
27
28
    /**
29
     * @param string $field
30
     * @param integer|string $value
31
     * @return Struct\PhpSettings
32
     */
33 View Code Duplication
    public function getPhpSettings($field, $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        $packet = $this->_client->getPacket();
36
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
37
38
        $getTag->addChild('filter')->addChild($field, $value);
39
        $getTag->addChild('dataset')->addChild('php-settings');
40
41
        $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
42
43
        return new Struct\PhpSettings($response);
44
    }
45
46
    /**
47
     * @param string $field
48
     * @param integer|string $value
49
     * @return Struct\Limits
50
     */
51
    public function getLimits($field, $value)
52
    {
53
        $items = $this->_getItems(Struct\Limits::class, 'limits', $field, $value);
54
        return reset($items);
55
    }
56
57
    /**
58
     * @param array $properties
59
     * @param array|null $hostingProperties
60
     * @param $planName
61
     * @return Struct\Info
62
     */
63
    public function create(array $properties, array $hostingProperties = null, $planName = null)
64
    {
65
        $packet = $this->_client->getPacket();
66
        $info = $packet->addChild($this->_wrapperTag)->addChild('add');
67
68
        $infoGeneral = $info->addChild('gen_setup');
69
        foreach ($properties as $name => $value) {
70
            $infoGeneral->addChild($name, $value);
71
        }
72
73
        if ($hostingProperties) {
74
            $infoHosting = $info->addChild('hosting')->addChild('vrt_hst');
75
            foreach ($hostingProperties as $name => $value) {
76
                $property = $infoHosting->addChild('property');
77
                $property->addChild('name', $name);
78
                $property->addChild('value', $value);
79
            }
80
81
            if (isset($properties['ip_address'])) {
82
                $infoHosting->addChild("ip_address", $properties['ip_address']);
83
            }
84
        }
85
86
        if ($planName) {
87
            $info->addChild('plan-name', $planName);
88
        }
89
90
        $response = $this->_client->request($packet);
91
        return new Struct\Info($response);
92
    }
93
94
    /**
95
     * @param string $field
96
     * @param integer|string $value
97
     * @return bool
98
     */
99
    public function delete($field, $value)
100
    {
101
        return $this->_delete($field, $value);
102
    }
103
104
    /**
105
     * @param string $field
106
     * @param integer|string $value
107
     * @return Struct\GeneralInfo
108
     */
109
    public function get($field, $value)
110
    {
111
        $items = $this->_getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
112
        return reset($items);
113
    }
114
115
    /**
116
     * @return Struct\GeneralInfo[]
117
     */
118
    public function getAll()
119
    {
120
        return $this->_getItems(Struct\GeneralInfo::class, 'gen_info');
121
    }
122
123
    /**
124
     * @param string $field
125
     * @param integer|string $value
126
     * @return Struct\DiskUsage
127
     */
128
    public function getDiskUsage($field, $value)
129
    {
130
        $items = $this->_getItems(Struct\DiskUsage::class, 'disk_usage', $field, $value);
131
        return reset($items);
132
    }
133
}
134