Completed
Pull Request — master (#137)
by
unknown
11:35
created

FacebookSdk   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
B setValue() 0 29 3
A getValue() 0 4 1
1
<?php
2
3
namespace AppBundle\Services;
4
use \Facebook;
5
6
class FacebookSdk
7
{
8
 private $userNode;
9
 private $appId;
10
 private $appSecret;
11
 private $graf_version;
12
 public  $accessToken;
13
 public function __construct($appId, $appSecret, $graf_version){
14
     $this->appId=$appId;
15
     $this->appSecret=$appSecret;
16
     $this->graf_version=$graf_version;
17
 }
18
 public function setValue($accessToken)
19
 {
20
     $fb = new \Facebook\Facebook([
21
22
         'app_id' => $this->appId,
23
         'app_secret' => $this->appSecret,
24
         'default_graph_version' => $this->graf_version,
25
     ]);
26
      //$helper = $fb->getJavaScriptHelper();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
     //$accessToken = $helper->getAccessToken();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
     //dump($accessToken);
29
30
31
     $fb->setDefaultAccessToken($accessToken);
32
33
     try {
34
         $response = $fb->get('/me?fields=id,name,email');
35
         // $userNode = $response->getGraphUser();
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
36
         $this->userNode = $response->getGraphUser();
37
     } catch (Facebook\Exceptions\FacebookResponseException $e) {
38
         // When Graph returns an error
39
         echo 'Graph returned an error: ' . $e->getMessage();
40
         exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method setValue() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
41
     } catch (Facebook\Exceptions\FacebookSDKException $e) {
42
         // When validation fails or other local issues
43
         echo 'Facebook SDK returned an error: ' . $e->getMessage();
44
         exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method setValue() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
45
     }
46
 }
47
     public function getValue()
48
     {
49
         return $this->userNode;
50
     }
51
 }
52
53