Completed
Pull Request — master (#144)
by
unknown
12:31
created

FacebookUserProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getUser() 0 18 2
1
<?php
2
3
namespace AppBundle\Services;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\Exception\TransferException;
7
use Symfony\Component\HttpKernel\Exception\HttpException;
8
9
class FacebookUserProvider
10
{
11
    /**
12
     * @param string $accessToken
13
     *
14
     * @return mixed
15
     */
16
    public function getUser($accessToken)
17
    {
18
        try {
19
            $client = new Client();
20
            $result = $client->get(
21
                'https://graph.facebook.com/v2.8/me',
22
                ['query' => [
23
                    'access_token' => $accessToken,
24
                    'fields' => 'id, email, first_name, last_name', ],
25
                ]
26
            );
27
            $userFacebook = json_decode($result->getBody());
28
29
            return $userFacebook;
30
        } catch (TransferException $e) {
31
            throw new HttpException(400, 'Social login error');
32
        }
33
    }
34
}
35