Skip to content

Commit

Permalink
Apply fixes from StyleCI (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
sohaibilyas authored May 17, 2020
1 parent 15d1a10 commit f915086
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ class Facebook

public function __construct(array $config = null)
{
if (!$config) {
if (! $config) {
throw new Exception('config array not provided to contructer');
}

if (!isset($config['app_id']) || $config['app_id'] == '') {
if (! isset($config['app_id']) || $config['app_id'] == '') {
throw new Exception('app_id not set in config array');
}

if (!isset($config['app_secret']) || $config['app_secret'] == '') {
if (! isset($config['app_secret']) || $config['app_secret'] == '') {
throw new Exception('app_secret not set in config array');
}

if (!isset($config['redirect_uri']) || $config['redirect_uri'] == '') {
if (! isset($config['redirect_uri']) || $config['redirect_uri'] == '') {
throw new Exception('redirect_uri not set in config array');
}

Expand Down Expand Up @@ -60,7 +60,7 @@ public function getAccessToken()

public function loggedIn()
{
if (!empty($this->accessToken)) {
if (! empty($this->accessToken)) {
return true;
}

Expand All @@ -69,7 +69,7 @@ public function loggedIn()
throw new Exception('state token did not match');
}

$this->accessToken = json_decode($this->client->get($this->graphVersion . '/oauth/access_token?client_id=' . $this->config['app_id'] . '&client_secret=' . $this->config['app_secret'] . '&redirect_uri=' . $this->config['redirect_uri'] . '&code=' . $_GET['code'])->getBody())->access_token;
$this->accessToken = json_decode($this->client->get($this->graphVersion.'/oauth/access_token?client_id='.$this->config['app_id'].'&client_secret='.$this->config['app_secret'].'&redirect_uri='.$this->config['redirect_uri'].'&code='.$_GET['code'])->getBody())->access_token;

return true;
}
Expand All @@ -83,12 +83,12 @@ public function getLoginUrl(array $permissions = [])
$this->state = bin2hex(random_bytes(20));
$_SESSION['state'] = $this->state;

return 'https://www.facebook.com/' . $this->graphVersion . '/dialog/oauth?client_id=' . $this->config['app_id'] . '&redirect_uri=' . $this->config['redirect_uri'] . '&scope=' . $permissions . '&state=' . $this->state;
return 'https://www.facebook.com/'.$this->graphVersion.'/dialog/oauth?client_id='.$this->config['app_id'].'&redirect_uri='.$this->config['redirect_uri'].'&scope='.$permissions.'&state='.$this->state;
}

public function post(string $path, array $params, string $accessToken = null)
{
$path = $path[0] == '/' ? $path : '/' . $path;
$path = $path[0] == '/' ? $path : '/'.$path;

$this->accessToken = $accessToken ? $accessToken : $this->accessToken;

Expand All @@ -97,7 +97,7 @@ public function post(string $path, array $params, string $accessToken = null)
$separator = '&';
}

$this->response = $this->client->post($this->graphVersion . $path . $separator . 'access_token=' . $this->accessToken, [
$this->response = $this->client->post($this->graphVersion.$path.$separator.'access_token='.$this->accessToken, [
'json' => $params,
]);

Expand All @@ -106,7 +106,7 @@ public function post(string $path, array $params, string $accessToken = null)

public function get(string $path, string $accessToken = null)
{
$path = $path[0] == '/' ? $path : '/' . $path;
$path = $path[0] == '/' ? $path : '/'.$path;

$this->accessToken = $accessToken ? $accessToken : $this->accessToken;

Expand All @@ -115,14 +115,14 @@ public function get(string $path, string $accessToken = null)
$separator = '&';
}

$this->response = $this->client->get($this->graphVersion . $path . $separator . 'access_token=' . $this->accessToken);
$this->response = $this->client->get($this->graphVersion.$path.$separator.'access_token='.$this->accessToken);

return $this;
}

public function delete(string $path, string $accessToken = null)
{
$path = $path[0] == '/' ? $path : '/' . $path;
$path = $path[0] == '/' ? $path : '/'.$path;

$this->accessToken = $accessToken ? $accessToken : $this->accessToken;

Expand All @@ -131,7 +131,7 @@ public function delete(string $path, string $accessToken = null)
$separator = '&';
}

$this->response = $this->client->delete($this->graphVersion . $path . $separator . 'access_token=' . $this->accessToken);
$this->response = $this->client->delete($this->graphVersion.$path.$separator.'access_token='.$this->accessToken);

return $this;
}
Expand Down

0 comments on commit f915086

Please sign in to comment.