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

Reseller   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 3
dl 53
loc 53
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 12 12 2
A delete() 4 4 1
A get() 5 5 1
A getAll() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
// Copyright 1999-2016. Parallels IP Holdings GmbH.
3
4
namespace PleskX\Api\Operator;
5
use PleskX\Api\Struct\Reseller as Struct;
6
7 View Code Duplication
class Reseller 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
    /**
39
     * @param string $field
40
     * @param integer|string $value
41
     * @return Struct\GeneralInfo
42
     */
43
    public function get($field, $value)
44
    {
45
        $items = $this->_getItems(Struct\GeneralInfo::class, 'gen-info', $field, $value);
46
        return reset($items);
47
    }
48
49
    /**
50
     * @return Struct\GeneralInfo[]
51
     */
52
    public function getAll()
53
    {
54
        return $this->_getItems(Struct\GeneralInfo::class, 'gen-info');
55
    }
56
57
58
59
}
60