Completed
Pull Request — master (#22)
by
unknown
13:28
created

LinkedInResourceOwner::getImageurl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php namespace League\OAuth2\Client\Provider;
2
3
use League\OAuth2\Client\Tool\ArrayAccessorTrait;
4
5
/**
6
 * @property array $response
7
 * @property string $uid
8
 */
9
class LinkedInResourceOwner extends GenericResourceOwner
10
{
11
12
    use ArrayAccessorTrait;
13
14
    /**
15
     * Raw response
16
     *
17
     * @var array
18
     */
19
    protected $response;
20
21
    /**
22
     * Creates new resource owner.
23
     *
24
     * @param array  $response
25
     */
26 6
    public function __construct(array $response = array())
27
    {
28 6
        $this->response = $response;
29 6
    }
30
31
    /**
32
     * Gets resource owner attribute by key. The key supports dot notation.
33
     *
34
     * @return mixed
35
     */
36 6
    public function getAttribute($key)
37
    {
38 6
        return $this->getValueByKey($this->response, (string) $key);
39
    }
40
41
    /**
42
     * Get user email
43
     *
44
     * @return string|null
45
     */
46 6
    public function getEmail()
47
    {
48 6
        return $this->getAttribute('emailAddress');
49
    }
50
51
    /**
52
     * Get user firstname
53
     *
54
     * @return string|null
55
     */
56 6
    public function getFirstName()
57
    {
58 6
        return $this->getAttribute('firstName');
59
    }
60
61
    /**
62
     * Get user imageurl
63
     *
64
     * @return string|null
65
     */
66 6
    public function getImageurl()
67
    {
68 6
        return $this->getAttribute('pictureUrl');
69
    }
70
71
    /**
72
     * Get user lastname
73
     *
74
     * @return string|null
75
     */
76 6
    public function getLastName()
77
    {
78 6
        return $this->getAttribute('lastName');
79
    }
80
81
    /**
82
     * Get user userId
83
     *
84
     * @return string|null
85
     */
86 6
    public function getId()
87
    {
88 6
        return $this->getAttribute('id');
89
    }
90
91
    /**
92
     * Get user location
93
     *
94
     * @return string|null
95
     */
96 6
    public function getLocation()
97
    {
98 6
        return $this->getAttribute('location.name');
99
    }
100
101
    /**
102
     * Get user description
103
     *
104
     * @return string|null
105
     */
106 6
    public function getDescription()
107
    {
108 6
        return $this->getAttribute('headline');
109
    }
110
111
    /**
112
     * Get user url
113
     *
114
     * @return string|null
115
     */
116 6
    public function getUrl()
117
    {
118 6
        return $this->getAttribute('publicProfileUrl');
119
    }
120
121
    /**
122
     * Get user summary
123
     *
124
     * @return string|null
125
     */
126 6
    public function getSummary()
127
    {
128 6
        return $this->getAttribute('summary');
129
    }
130
131
    /**
132
     * @return string
133
     */
134
    public function __toString()
135
    {
136 6
        return $this->getFirstName() || '';
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->getFirstName() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
137
    }
138
}
139