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

GuzzleClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getUserFacebook() 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 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