Element   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 49
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 3
A setIdColumn() 0 5 1
A getIdColumn() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace Acquia\Rest;
4
5
use Guzzle\Http\Message\Request;
6
7
class Element extends \ArrayObject
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $idColumn = 'name';
13
14
    /**
15
     * @param string|array|\Guzzle\Http\Message\Request $array
0 ignored issues
show
Bug introduced by
There is no parameter named $array. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
16
     */
17 144
    public function __construct($data)
18
    {
19 144
        if ($data instanceof Request) {
20 105
            $array = $data->send()->json();
21 144
        } elseif (is_string($data)) {
22 6
            $array = array($this->idColumn => $data);
23 6
        } else {
24 33
            $array = (array) $data;
25
        }
26 144
        parent::__construct($array);
27 144
    }
28
29
    /**
30
     * @param string $idColumn
31
     *
32
     * @return \Acquia\Rest\Element
33
     */
34 3
    public function setIdColumn($idColumn)
35
    {
36 3
        $this->idColumn = $idColumn;
37 3
        return $this;
38
    }
39
40
    /**
41
     * @return string|int
42
     */
43 3
    public function getIdColumn()
44
    {
45 3
        return $this->idColumn;
46
    }
47
48
    /**
49
     * @return string
50
     */
51 132
    public function __toString()
52
    {
53 132
        return $this[$this->idColumn];
54
    }
55
}
56