Completed
Push — master ( 9902d6...c7939a )
by Alexei
10s
created

PhpHandler::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
// Copyright 1999-2018. Parallels IP Holdings 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
    public function get($field, $value)
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