Completed
Push — master ( 841fdc...5147f3 )
by Alexei
02:10
created

Customer::_get()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 12

Duplication

Lines 21
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 21
loc 21
rs 9.3142
cc 3
eloc 12
nc 4
nop 2
1
<?php
2
// Copyright 1999-2016. Parallels IP Holdings GmbH.
3
4
namespace PleskX\Api\Operator;
5
use PleskX\Api\Struct\Customer as Struct;
6
7 View Code Duplication
class Customer extends \PleskX\Api\Operator
0 ignored issues
show
Duplication introduced by
This class 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...
8
{
9
10
    /**
11
     * @param array $properties
12
     * @return Struct\Info
13
     */
14
    public function create($properties)
15
    {
16
        $packet = $this->_client->getPacket();
17
        $info = $packet->addChild($this->_wrapperTag)->addChild('add')->addChild('gen_info');
18
19
        foreach ($properties as $name => $value) {
20
            $info->addChild($name, $value);
21
        }
22
23
        $response = $this->_client->request($packet);
24
        return new Struct\Info($response);
25
    }
26
27
    /**
28
     * @param string $field
29
     * @param integer|string $value
30
     * @return bool
31
     */
32
    public function delete($field, $value)
33
    {
34
        return $this->_delete($field, $value);
35
    }
36
37
    /**
38
     * @param string $field
39
     * @param integer|string $value
40
     * @return Struct\GeneralInfo
41
     */
42
    public function get($field, $value)
43
    {
44
        $items = $this->_getItems(Struct\GeneralInfo::class, 'gen_info', $field, $value);
45
        return reset($items);
46
    }
47
48
    /**
49
     * @return Struct\GeneralInfo[]
50
     */
51
    public function getAll()
52
    {
53
        return $this->_getItems(Struct\GeneralInfo::class, 'gen_info');
54
    }
55
56
}
57