Element::setIdColumn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 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