Completed
Pull Request — master (#137)
by
unknown
14:15
created

GuzzleClient::getUserFacebook()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 12
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 18
rs 9.4285
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 GuzzleClient
10
{
11
    /**
12
     * @param string $accessToken
13
     *
14
     * @return object
15
     */
16
    public function getUserFacebook($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) {
0 ignored issues
show
Bug introduced by
The class GuzzleHttp\Exception\TransferException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
31
            throw new HttpException(400, 'Social login error');
32
        }
33
    }
34
}
35