Code Duplication    Length = 19-19 lines in 4 locations

src/PleskX/Api/Operator/DatabaseServer.php 1 location

@@ 46-64 (lines=19) @@
43
     * @param integer|string|null $value
44
     * @return Struct\Info|Struct\Info[]
45
     */
46
    private function _get($field = null, $value = null)
47
    {
48
        $packet = $this->_client->getPacket();
49
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
50
51
        $filterTag = $getTag->addChild('filter');
52
        if (!is_null($field)) {
53
            $filterTag->addChild($field, $value);
54
        }
55
56
        $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
57
58
        $items = [];
59
        foreach ($response->xpath('//result') as $xmlResult) {
60
            $items[] = new Struct\Info($xmlResult->data);
61
        }
62
63
        return $items;
64
    }
65
66
}
67

src/PleskX/Api/Operator/ServicePlan.php 1 location

@@ 35-53 (lines=19) @@
32
     * @param integer|string|null $value
33
     * @return Struct\Info|Struct\Info[]
34
     */
35
    private function _get($field = null, $value = null)
36
    {
37
        $packet = $this->_client->getPacket();
38
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
39
40
        $filterTag = $getTag->addChild('filter');
41
        if (!is_null($field)) {
42
            $filterTag->addChild($field, $value);
43
        }
44
45
        $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
46
47
        $items = [];
48
        foreach ($response->xpath('//result') as $xmlResult) {
49
            $items[] = new Struct\Info($xmlResult);
50
        }
51
52
        return $items;
53
    }
54
55
}
56

src/PleskX/Api/Operator/SecretKey.php 1 location

@@ 55-73 (lines=19) @@
52
     * @param string|null $keyId
53
     * @return Struct\Info[]
54
     */
55
    public function _get($keyId = null)
56
    {
57
        $packet = $this->_client->getPacket();
58
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get_info');
59
60
        $filterTag = $getTag->addChild('filter');
61
        if (!is_null($keyId)) {
62
            $filterTag->addChild('key', $keyId);
63
        }
64
65
        $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
66
67
        $items = [];
68
        foreach ($response->xpath('//result') as $xmlResult) {
69
            $items[] = new Struct\Info($xmlResult->key_info);
70
        }
71
72
        return $items;
73
    }
74
75
}
76

src/PleskX/Api/Operator/Database.php 1 location

@@ 31-49 (lines=19) @@
28
     * @param integer|string $value
29
     * @return Struct\Info[]
30
     */
31
    public function get($field, $value)
32
    {
33
        $packet = $this->_client->getPacket();
34
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get-db');
35
36
        $filterTag = $getTag->addChild('filter');
37
        if (!is_null($field)) {
38
            $filterTag->addChild($field, $value);
39
        }
40
41
        $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
42
43
        $items = [];
44
        foreach ( $response->xpath('//result')as $xmlResult) {
45
            $items[] = new Struct\Info($xmlResult);
46
        }
47
48
        return $items;
49
    }
50
51
    /**
52
     * @param string $field