Code Duplication    Length = 19-21 lines in 3 locations

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

@@ 46-66 (lines=21) @@
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
            $item = new Struct\Info($xmlResult->data);
61
            $item->id = (int)$xmlResult->id;
62
            $items[] = $item;
63
        }
64
65
        return $items;
66
    }
67
68
}
69

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

@@ 52-72 (lines=21) @@
49
     * @param integer|string $value
50
     * @return Struct\Info[]
51
     */
52
    public function getAll($field = null, $value = null)
53
    {
54
        $packet = $this->_client->getPacket();
55
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
56
57
        $filterTag = $getTag->addChild('filter');
58
        if (!is_null($field)) {
59
            $filterTag->addChild($field, $value);
60
        }
61
62
        $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
63
64
        $items = [];
65
        foreach ($response->xpath('//result') as $xmlResult) {
66
            $item = new Struct\Info($xmlResult->data);
67
            $item->id = (int)$xmlResult->id;
68
            $items[] = $item;
69
        }
70
71
        return $items;
72
    }
73
}
74

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

@@ 40-58 (lines=19) @@
37
     * @param integer|string $value
38
     * @return Struct\Info[]
39
     */
40
    public function getAll($field, $value)
41
    {
42
        $packet = $this->_client->getPacket();
43
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get_rec');
44
45
        $filterTag = $getTag->addChild('filter');
46
        if (!is_null($field)) {
47
            $filterTag->addChild($field, $value);
48
        }
49
50
        $response = $this->_client->request($packet, \PleskX\Api\Client::RESPONSE_FULL);
51
        $items = [];
52
        foreach ($response->xpath('//result') as $xmlResult) {
53
            $item = new Struct\Info($xmlResult->data);
54
            $item->id = (int)$xmlResult->id;
55
            $items[] = $item;
56
        }
57
        return $items;
58
    }
59
60
    /**
61
     * @param string $field