Passed
Push — heiglandreas-patch-1 ( 8f4377 )
by Andreas
03:21
created

GitLab   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 58
ccs 12
cts 15
cp 0.8
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getScopeInline() 0 3 1
A getRequestTokenUri() 0 3 1
A getName() 0 3 1
A getBaseUri() 0 3 1
A getAuthorizeUri() 0 3 1
A getIdentity() 0 11 1
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
declare(strict_types=1);
7
8
namespace SocialConnect\OAuth2\Provider;
9
10
use SocialConnect\Common\ArrayHydrator;
11
use SocialConnect\Provider\AccessTokenInterface;
12
use SocialConnect\Common\Entity\User;
0 ignored issues
show
Bug introduced by
The type SocialConnect\Common\Entity\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class GitLab extends \SocialConnect\OAuth2\AbstractProvider
15
{
16
    const NAME = 'gitlab';
17
18
    /**
19
     * {@inheritdoc}
20
     */
21 3
    public function getBaseUri()
22
    {
23 3
        return 'https://gitlab.com/api/v3/';
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public function getAuthorizeUri()
30
    {
31 2
        return 'https://gitlab.com/oauth/authorize';
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 2
    public function getRequestTokenUri()
38
    {
39 2
        return 'https://gitlab.com/oauth/token';
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 3
    public function getName()
46
    {
47 3
        return self::NAME;
48
    }
49
50
    /**
51
     * @return string
52
     */
53 1
    public function getScopeInline()
54
    {
55 1
        return implode('+', $this->scope);
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 2
    public function getIdentity(AccessTokenInterface $accessToken)
62
    {
63 2
        $response = $this->request('GET', 'user', [], $accessToken);
64
65
        $hydrator = new ArrayHydrator([
66
            'user_id' => 'id',
67
            'name' => 'fullname',
68
            'avatar_url' => 'pictureURL'
69
        ]);
70
71
        return $hydrator->hydrate(new User(), $response);
72
    }
73
}
74