Completed
Push — master ( 1873c2...edf903 )
by
unknown
03:17 queued 01:42
created

PhpHandler::getAll()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
dl 19
loc 19
rs 9.6333
c 0
b 0
f 0
cc 3
nc 4
nop 2
1
<?php
2
// Copyright 1999-2019. Plesk International GmbH.
3
4
namespace PleskX\Api\Operator;
5
6
use PleskX\Api\Client;
7
use PleskX\Api\Operator;
8
use PleskX\Api\Struct\PhpHandler\Info;
9
10
class PhpHandler extends Operator
11
{
12
    /**
13
     * @param string $field
14
     * @param integer|string $value
15
     * @return Info
16
     */
17 View Code Duplication
    public function get($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...
18
    {
19
        $packet = $this->_client->getPacket();
20
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
21
        $filterTag = $getTag->addChild('filter');
22
23
        if (!is_null($field)) {
24
            $filterTag->addChild($field, $value);
25
        }
26
27
        $response = $this->_client->request($packet, Client::RESPONSE_FULL);
28
        $xmlResult = $response->xpath('//result')[0];
29
30
        return new Info($xmlResult);
31
    }
32
33
    /**
34
     * @param string|null $field
35
     * @param integer|string $value
36
     * @return Info[]
37
     */
38 View Code Duplication
    public function getAll($field = null, $value = null)
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...
39
    {
40
        $packet = $this->_client->getPacket();
41
        $getTag = $packet->addChild($this->_wrapperTag)->addChild('get');
42
43
        $filterTag = $getTag->addChild('filter');
44
        if (!is_null($field)) {
45
            $filterTag->addChild($field, $value);
46
        }
47
48
        $response = $this->_client->request($packet, Client::RESPONSE_FULL);
49
        $items = [];
50
        foreach ($response->xpath('//result') as $xmlResult) {
51
            $item = new Info($xmlResult);
52
            $items[] = $item;
53
        }
54
55
        return $items;
56
    }
57
}
58