StackExchangeResourceOwner::getId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace AlexMasterov\OAuth2\Client\Provider;
5
6
use League\OAuth2\Client\{
7
    Provider\ResourceOwnerInterface,
8
    Tool\ArrayAccessorTrait
9
};
10
11
class StackExchangeResourceOwner implements ResourceOwnerInterface
12
{
13
    use ArrayAccessorTrait;
14
15 1
    public function __construct(array $response = [])
16
    {
17 1
        $this->items = $this->getValueByKey($response, 'items', []);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getValueByKey($response, 'items', array()) of type * is incompatible with the declared type array of property $items.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
18 1
    }
19
20
    /**
21
     * @return array
22
     */
23 1
    public function getId()
24
    {
25 1
        $items = $this->items;
26
27 1
        $ids = [];
28 1
        foreach ($items as $item) {
29 1
            $ids[] = $this->getValueByKey($item, 'user_id');
30
        }
31
32 1
        return $ids;
33
    }
34
35
    /**
36
     * @return array
37
     */
38 1
    public function toArray()
39
    {
40 1
        return $this->items;
41
    }
42
43
    /**
44
     * @var array
45
     */
46
    protected $items = [];
47
}
48