Completed
Push — master ( b7d668...770957 )
by Gallice
02:33
created

BufferUser::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Tgallice\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
6
7
class BufferUser implements ResourceOwnerInterface
8
{
9
    /**
10
     * @var array
11
     */
12
    private $response;
13
14
    /**
15
     * @var array
16
     */
17
    private $defaultFields = array(
18
        'id' => null,
19
        'name' => null,
20
    );
21
22
    /**
23
     * @param array $response
24
     */
25 2
    public function __construct(array $response = array())
26
    {
27 2
        $this->response = array_merge($this->defaultFields, $response);
28 2
    }
29
30
    /**
31
     * Get the ID for the user
32
     *
33
     * @return string|null
34
     */
35 2
    public function getId()
36
    {
37 2
        return $this->response['id'];
38
    }
39
40
    /**
41
     * Get the name for the user
42
     *
43
     * @return string|null
44
     */
45 2
    public function getName()
46
    {
47 2
        return $this->response['name'];
48
    }
49
50
    /**
51
     * Return all the data for the user
52
     *
53
     * @return array
54
     */
55 2
    public function toArray()
56
    {
57 2
        return $this->response;
58
    }
59
}
60