Passed
Push — master ( bd5724...8a312b )
by
unknown
01:47
created
src/Provider/Discord.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
         $data = new Data\Collection($response);
67 67
 
68
-        if (!$data->exists('id')) {
68
+        if ( ! $data->exists('id')) {
69 69
             throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
70 70
         }
71 71
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
         if ($data->get('avatar')) {
89 89
             $userProfile->photoURL = 'https://cdn.discordapp.com/avatars/';
90
-            $userProfile->photoURL .= $data->get('id') . '/' . $data->get('avatar') . '.png';
90
+            $userProfile->photoURL .= $data->get('id').'/'.$data->get('avatar').'.png';
91 91
         }
92 92
 
93 93
         return $userProfile;
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -17,80 +17,80 @@
 block discarded – undo
17 17
  */
18 18
 class Discord extends OAuth2
19 19
 {
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $scope = 'identify email';
24
-
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $apiBaseUrl = 'https://discordapp.com/api/';
29
-
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $authorizeUrl = 'https://discordapp.com/api/oauth2/authorize';
34
-
35
-    /**
36
-     * {@inheritdoc}
37
-     */
38
-    protected $accessTokenUrl = 'https://discordapp.com/api/oauth2/token';
39
-
40
-    /**
41
-     * {@inheritdoc}
42
-     */
43
-    protected $apiDocumentation = 'https://discordapp.com/developers/docs/topics/oauth2';
44
-
45
-    /**
46
-     * {@inheritdoc}
47
-     */
48
-    protected function initialize()
49
-    {
50
-        parent::initialize();
51
-
52
-        if ($this->isRefreshTokenAvailable()) {
53
-            $this->tokenRefreshParameters += [
54
-                'client_id' => $this->clientId,
55
-                'client_secret' => $this->clientSecret,
56
-            ];
57
-        }
58
-    }
59
-
60
-    /**
61
-     * {@inheritdoc}
62
-     */
63
-    public function getUserProfile()
64
-    {
65
-        $response = $this->apiRequest('users/@me');
66
-
67
-        $data = new Data\Collection($response);
68
-
69
-        if (!$data->exists('id')) {
70
-            throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
71
-        }
72
-
73
-        // Makes display name more unique.
74
-        $displayName = $data->get('username') ?: $data->get('login');
75
-        if ($discriminator = $data->get('discriminator')) {
76
-            $displayName .= "#{$discriminator}";
77
-        }
78
-
79
-        $userProfile = new User\Profile();
80
-
81
-        $userProfile->identifier = $data->get('id');
82
-        $userProfile->displayName = $displayName;
83
-        $userProfile->email = $data->get('email');
84
-
85
-        if ($data->get('verified')) {
86
-            $userProfile->emailVerified = $data->get('email');
87
-        }
88
-
89
-        if ($data->get('avatar')) {
90
-            $userProfile->photoURL = 'https://cdn.discordapp.com/avatars/';
91
-            $userProfile->photoURL .= $data->get('id') . '/' . $data->get('avatar') . '.png';
92
-        }
93
-
94
-        return $userProfile;
95
-    }
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $scope = 'identify email';
24
+
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $apiBaseUrl = 'https://discordapp.com/api/';
29
+
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $authorizeUrl = 'https://discordapp.com/api/oauth2/authorize';
34
+
35
+	/**
36
+	 * {@inheritdoc}
37
+	 */
38
+	protected $accessTokenUrl = 'https://discordapp.com/api/oauth2/token';
39
+
40
+	/**
41
+	 * {@inheritdoc}
42
+	 */
43
+	protected $apiDocumentation = 'https://discordapp.com/developers/docs/topics/oauth2';
44
+
45
+	/**
46
+	 * {@inheritdoc}
47
+	 */
48
+	protected function initialize()
49
+	{
50
+		parent::initialize();
51
+
52
+		if ($this->isRefreshTokenAvailable()) {
53
+			$this->tokenRefreshParameters += [
54
+				'client_id' => $this->clientId,
55
+				'client_secret' => $this->clientSecret,
56
+			];
57
+		}
58
+	}
59
+
60
+	/**
61
+	 * {@inheritdoc}
62
+	 */
63
+	public function getUserProfile()
64
+	{
65
+		$response = $this->apiRequest('users/@me');
66
+
67
+		$data = new Data\Collection($response);
68
+
69
+		if (!$data->exists('id')) {
70
+			throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
71
+		}
72
+
73
+		// Makes display name more unique.
74
+		$displayName = $data->get('username') ?: $data->get('login');
75
+		if ($discriminator = $data->get('discriminator')) {
76
+			$displayName .= "#{$discriminator}";
77
+		}
78
+
79
+		$userProfile = new User\Profile();
80
+
81
+		$userProfile->identifier = $data->get('id');
82
+		$userProfile->displayName = $displayName;
83
+		$userProfile->email = $data->get('email');
84
+
85
+		if ($data->get('verified')) {
86
+			$userProfile->emailVerified = $data->get('email');
87
+		}
88
+
89
+		if ($data->get('avatar')) {
90
+			$userProfile->photoURL = 'https://cdn.discordapp.com/avatars/';
91
+			$userProfile->photoURL .= $data->get('id') . '/' . $data->get('avatar') . '.png';
92
+		}
93
+
94
+		return $userProfile;
95
+	}
96 96
 }
Please login to merge, or discard this patch.
src/Provider/Dropbox.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
         $data = new Data\Collection($response);
53 53
 
54
-        if (!$data->exists('account_id') || !$data->get('account_id')) {
54
+        if ( ! $data->exists('account_id') || ! $data->get('account_id')) {
55 55
             throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56 56
         }
57 57
 
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -17,58 +17,58 @@
 block discarded – undo
17 17
  */
18 18
 class Dropbox extends OAuth2
19 19
 {
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $scope = 'account_info.read';
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $scope = 'account_info.read';
24 24
 
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $apiBaseUrl = 'https://api.dropbox.com/2/';
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $apiBaseUrl = 'https://api.dropbox.com/2/';
29 29
 
30
-    /**
31
-     * {@inheritdoc}
32
-     */
33
-    protected $authorizeUrl = 'https://www.dropbox.com/1/oauth2/authorize';
30
+	/**
31
+	 * {@inheritdoc}
32
+	 */
33
+	protected $authorizeUrl = 'https://www.dropbox.com/1/oauth2/authorize';
34 34
 
35
-    /**
36
-     * {@inheritdoc}
37
-     */
38
-    protected $accessTokenUrl = 'https://api.dropbox.com/1/oauth2/token';
35
+	/**
36
+	 * {@inheritdoc}
37
+	 */
38
+	protected $accessTokenUrl = 'https://api.dropbox.com/1/oauth2/token';
39 39
 
40
-    /**
41
-     * {@inheritdoc}
42
-     */
43
-    protected $apiDocumentation = 'https://www.dropbox.com/developers/documentation/http/documentation';
40
+	/**
41
+	 * {@inheritdoc}
42
+	 */
43
+	protected $apiDocumentation = 'https://www.dropbox.com/developers/documentation/http/documentation';
44 44
 
45
-    /**
46
-     * {@inheritdoc}
47
-     */
48
-    public function getUserProfile()
49
-    {
50
-        $response = $this->apiRequest('users/get_current_account', 'POST', [], [], true);
45
+	/**
46
+	 * {@inheritdoc}
47
+	 */
48
+	public function getUserProfile()
49
+	{
50
+		$response = $this->apiRequest('users/get_current_account', 'POST', [], [], true);
51 51
 
52
-        $data = new Data\Collection($response);
52
+		$data = new Data\Collection($response);
53 53
 
54
-        if (!$data->exists('account_id') || !$data->get('account_id')) {
55
-            throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56
-        }
54
+		if (!$data->exists('account_id') || !$data->get('account_id')) {
55
+			throw new UnexpectedApiResponseException('Provider API returned an unexpected response.');
56
+		}
57 57
 
58
-        $userProfile = new User\Profile();
58
+		$userProfile = new User\Profile();
59 59
 
60
-        $userProfile->identifier = $data->get('account_id');
61
-        $userProfile->displayName = $data->filter('name')->get('display_name');
62
-        $userProfile->firstName = $data->filter('name')->get('given_name');
63
-        $userProfile->lastName = $data->filter('name')->get('surname');
64
-        $userProfile->email = $data->get('email');
65
-        $userProfile->photoURL = $data->get('profile_photo_url');
66
-        $userProfile->language = $data->get('locale');
67
-        $userProfile->country = $data->get('country');
68
-        if ($data->get('email_verified')) {
69
-            $userProfile->emailVerified = $data->get('email');
70
-        }
60
+		$userProfile->identifier = $data->get('account_id');
61
+		$userProfile->displayName = $data->filter('name')->get('display_name');
62
+		$userProfile->firstName = $data->filter('name')->get('given_name');
63
+		$userProfile->lastName = $data->filter('name')->get('surname');
64
+		$userProfile->email = $data->get('email');
65
+		$userProfile->photoURL = $data->get('profile_photo_url');
66
+		$userProfile->language = $data->get('locale');
67
+		$userProfile->country = $data->get('country');
68
+		if ($data->get('email_verified')) {
69
+			$userProfile->emailVerified = $data->get('email');
70
+		}
71 71
 
72
-        return $userProfile;
73
-    }
72
+		return $userProfile;
73
+	}
74 74
 }
Please login to merge, or discard this patch.
src/Provider/WeChatChina.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -12,23 +12,23 @@
 block discarded – undo
12 12
  */
13 13
 class WeChatChina extends WeChat
14 14
 {
15
-    /**
16
-     * {@inheritdoc}
17
-     */
18
-    protected $apiBaseUrl = 'https://api.weixin.qq.com/sns/';
15
+	/**
16
+	 * {@inheritdoc}
17
+	 */
18
+	protected $apiBaseUrl = 'https://api.weixin.qq.com/sns/';
19 19
 
20
-    /**
21
-     * {@inheritdoc}
22
-     */
23
-    protected $accessTokenUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token';
20
+	/**
21
+	 * {@inheritdoc}
22
+	 */
23
+	protected $accessTokenUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token';
24 24
 
25
-    /**
26
-     * {@inheritdoc}
27
-     */
28
-    protected $tokenRefreshUrl = 'https://api.weixin.qq.com/sns/oauth2/refresh_token';
25
+	/**
26
+	 * {@inheritdoc}
27
+	 */
28
+	protected $tokenRefreshUrl = 'https://api.weixin.qq.com/sns/oauth2/refresh_token';
29 29
 
30
-    /**
31
-     * {@ịnheritdoc}
32
-     */
33
-    protected $accessTokenInfoUrl = 'https://api.weixin.qq.com/sns/auth';
30
+	/**
31
+	 * {@ịnheritdoc}
32
+	 */
33
+	protected $accessTokenInfoUrl = 'https://api.weixin.qq.com/sns/auth';
34 34
 }
Please login to merge, or discard this patch.
src/Logger/LoggerInterface.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -12,39 +12,39 @@
 block discarded – undo
12 12
  */
13 13
 interface LoggerInterface
14 14
 {
15
-    /**
16
-     * Interesting events.
17
-     *
18
-     * Example: User logs in, SQL logs.
19
-     *
20
-     * @param string $message
21
-     * @param array $context
22
-     */
23
-    public function info($message, array $context = array());
15
+	/**
16
+	 * Interesting events.
17
+	 *
18
+	 * Example: User logs in, SQL logs.
19
+	 *
20
+	 * @param string $message
21
+	 * @param array $context
22
+	 */
23
+	public function info($message, array $context = array());
24 24
 
25
-    /**
26
-     * Detailed debug information.
27
-     *
28
-     * @param string $message
29
-     * @param array $context
30
-     */
31
-    public function debug($message, array $context = array());
25
+	/**
26
+	 * Detailed debug information.
27
+	 *
28
+	 * @param string $message
29
+	 * @param array $context
30
+	 */
31
+	public function debug($message, array $context = array());
32 32
 
33
-    /**
34
-     * Runtime errors that do not require immediate action but should typically
35
-     * be logged and monitored.
36
-     *
37
-     * @param string $message
38
-     * @param array $context
39
-     */
40
-    public function error($message, array $context = array());
33
+	/**
34
+	 * Runtime errors that do not require immediate action but should typically
35
+	 * be logged and monitored.
36
+	 *
37
+	 * @param string $message
38
+	 * @param array $context
39
+	 */
40
+	public function error($message, array $context = array());
41 41
 
42
-    /**
43
-     * Logs with an arbitrary level.
44
-     *
45
-     * @param mixed $level
46
-     * @param string $message
47
-     * @param array $context
48
-     */
49
-    public function log($level, $message, array $context = array());
42
+	/**
43
+	 * Logs with an arbitrary level.
44
+	 *
45
+	 * @param mixed $level
46
+	 * @param string $message
47
+	 * @param array $context
48
+	 */
49
+	public function log($level, $message, array $context = array());
50 50
 }
Please login to merge, or discard this patch.
src/Logger/Logger.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -15,115 +15,115 @@
 block discarded – undo
15 15
  */
16 16
 class Logger implements LoggerInterface
17 17
 {
18
-    const NONE = 'none';  // turn logging off
19
-    const DEBUG = 'debug'; // debug, info and error messages
20
-    const INFO = 'info';  // info and error messages
21
-    const ERROR = 'error'; // only error messages
22
-
23
-    /**
24
-     * Debug level.
25
-     *
26
-     * One of Logger::NONE, Logger::DEBUG, Logger::INFO, Logger::ERROR
27
-     *
28
-     * @var string
29
-     */
30
-    protected $level;
31
-
32
-    /**
33
-     * Path to file writeable by the web server. Required if $this->level !== Logger::NONE.
34
-     *
35
-     * @var string
36
-     */
37
-    protected $file;
38
-
39
-    /**
40
-     * @param bool|string $level One of Logger::NONE, Logger::DEBUG, Logger::INFO, Logger::ERROR
41
-     * @param string $file File where to write messages
42
-     *
43
-     * @throws InvalidArgumentException
44
-     * @throws RuntimeException
45
-     */
46
-    public function __construct($level, $file)
47
-    {
48
-        $this->level = self::NONE;
49
-
50
-        if ($level && $level !== self::NONE) {
51
-            $this->initialize($file);
52
-
53
-            $this->level = $level === true ? Logger::DEBUG : $level;
54
-            $this->file = $file;
55
-        }
56
-    }
57
-
58
-    /**
59
-     * @param string $file
60
-     *
61
-     * @throws InvalidArgumentException
62
-     * @throws RuntimeException
63
-     */
64
-    protected function initialize($file)
65
-    {
66
-        if (!$file) {
67
-            throw new InvalidArgumentException('Log file is not specified.');
68
-        }
69
-
70
-        if (!file_exists($file) && !touch($file)) {
71
-            throw new RuntimeException(sprintf('Log file %s can not be created.', $file));
72
-        }
73
-
74
-        if (!is_writable($file)) {
75
-            throw new RuntimeException(sprintf('Log file %s is not writeable.', $file));
76
-        }
77
-    }
78
-
79
-    /**
80
-     * @inheritdoc
81
-     */
82
-    public function info($message, array $context = [])
83
-    {
84
-        if (!in_array($this->level, [self::DEBUG, self::INFO])) {
85
-            return;
86
-        }
87
-
88
-        $this->log(self::INFO, $message, $context);
89
-    }
90
-
91
-    /**
92
-     * @inheritdoc
93
-     */
94
-    public function debug($message, array $context = [])
95
-    {
96
-        if (!in_array($this->level, [self::DEBUG])) {
97
-            return;
98
-        }
99
-
100
-        $this->log(self::DEBUG, $message, $context);
101
-    }
102
-
103
-    /**
104
-     * @inheritdoc
105
-     */
106
-    public function error($message, array $context = [])
107
-    {
108
-        if (!in_array($this->level, [self::DEBUG, self::INFO, self::ERROR])) {
109
-            return;
110
-        }
111
-
112
-        $this->log(self::ERROR, $message, $context);
113
-    }
114
-
115
-    /**
116
-     * @inheritdoc
117
-     */
118
-    public function log($level, $message, array $context = [])
119
-    {
120
-        $datetime = new \DateTime();
121
-        $datetime = $datetime->format(DATE_ATOM);
122
-
123
-        $content = sprintf('%s -- %s -- %s -- %s', $level, $_SERVER['REMOTE_ADDR'], $datetime, $message);
124
-        $content .= ($context ? "\n" . print_r($context, true) : '');
125
-        $content .= "\n";
126
-
127
-        file_put_contents($this->file, $content, FILE_APPEND);
128
-    }
18
+	const NONE = 'none';  // turn logging off
19
+	const DEBUG = 'debug'; // debug, info and error messages
20
+	const INFO = 'info';  // info and error messages
21
+	const ERROR = 'error'; // only error messages
22
+
23
+	/**
24
+	 * Debug level.
25
+	 *
26
+	 * One of Logger::NONE, Logger::DEBUG, Logger::INFO, Logger::ERROR
27
+	 *
28
+	 * @var string
29
+	 */
30
+	protected $level;
31
+
32
+	/**
33
+	 * Path to file writeable by the web server. Required if $this->level !== Logger::NONE.
34
+	 *
35
+	 * @var string
36
+	 */
37
+	protected $file;
38
+
39
+	/**
40
+	 * @param bool|string $level One of Logger::NONE, Logger::DEBUG, Logger::INFO, Logger::ERROR
41
+	 * @param string $file File where to write messages
42
+	 *
43
+	 * @throws InvalidArgumentException
44
+	 * @throws RuntimeException
45
+	 */
46
+	public function __construct($level, $file)
47
+	{
48
+		$this->level = self::NONE;
49
+
50
+		if ($level && $level !== self::NONE) {
51
+			$this->initialize($file);
52
+
53
+			$this->level = $level === true ? Logger::DEBUG : $level;
54
+			$this->file = $file;
55
+		}
56
+	}
57
+
58
+	/**
59
+	 * @param string $file
60
+	 *
61
+	 * @throws InvalidArgumentException
62
+	 * @throws RuntimeException
63
+	 */
64
+	protected function initialize($file)
65
+	{
66
+		if (!$file) {
67
+			throw new InvalidArgumentException('Log file is not specified.');
68
+		}
69
+
70
+		if (!file_exists($file) && !touch($file)) {
71
+			throw new RuntimeException(sprintf('Log file %s can not be created.', $file));
72
+		}
73
+
74
+		if (!is_writable($file)) {
75
+			throw new RuntimeException(sprintf('Log file %s is not writeable.', $file));
76
+		}
77
+	}
78
+
79
+	/**
80
+	 * @inheritdoc
81
+	 */
82
+	public function info($message, array $context = [])
83
+	{
84
+		if (!in_array($this->level, [self::DEBUG, self::INFO])) {
85
+			return;
86
+		}
87
+
88
+		$this->log(self::INFO, $message, $context);
89
+	}
90
+
91
+	/**
92
+	 * @inheritdoc
93
+	 */
94
+	public function debug($message, array $context = [])
95
+	{
96
+		if (!in_array($this->level, [self::DEBUG])) {
97
+			return;
98
+		}
99
+
100
+		$this->log(self::DEBUG, $message, $context);
101
+	}
102
+
103
+	/**
104
+	 * @inheritdoc
105
+	 */
106
+	public function error($message, array $context = [])
107
+	{
108
+		if (!in_array($this->level, [self::DEBUG, self::INFO, self::ERROR])) {
109
+			return;
110
+		}
111
+
112
+		$this->log(self::ERROR, $message, $context);
113
+	}
114
+
115
+	/**
116
+	 * @inheritdoc
117
+	 */
118
+	public function log($level, $message, array $context = [])
119
+	{
120
+		$datetime = new \DateTime();
121
+		$datetime = $datetime->format(DATE_ATOM);
122
+
123
+		$content = sprintf('%s -- %s -- %s -- %s', $level, $_SERVER['REMOTE_ADDR'], $datetime, $message);
124
+		$content .= ($context ? "\n" . print_r($context, true) : '');
125
+		$content .= "\n";
126
+
127
+		file_put_contents($this->file, $content, FILE_APPEND);
128
+	}
129 129
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class Logger implements LoggerInterface
17 17
 {
18
-    const NONE = 'none';  // turn logging off
18
+    const NONE = 'none'; // turn logging off
19 19
     const DEBUG = 'debug'; // debug, info and error messages
20
-    const INFO = 'info';  // info and error messages
20
+    const INFO = 'info'; // info and error messages
21 21
     const ERROR = 'error'; // only error messages
22 22
 
23 23
     /**
@@ -63,15 +63,15 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function initialize($file)
65 65
     {
66
-        if (!$file) {
66
+        if ( ! $file) {
67 67
             throw new InvalidArgumentException('Log file is not specified.');
68 68
         }
69 69
 
70
-        if (!file_exists($file) && !touch($file)) {
70
+        if ( ! file_exists($file) && ! touch($file)) {
71 71
             throw new RuntimeException(sprintf('Log file %s can not be created.', $file));
72 72
         }
73 73
 
74
-        if (!is_writable($file)) {
74
+        if ( ! is_writable($file)) {
75 75
             throw new RuntimeException(sprintf('Log file %s is not writeable.', $file));
76 76
         }
77 77
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function info($message, array $context = [])
83 83
     {
84
-        if (!in_array($this->level, [self::DEBUG, self::INFO])) {
84
+        if ( ! in_array($this->level, [self::DEBUG, self::INFO])) {
85 85
             return;
86 86
         }
87 87
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function debug($message, array $context = [])
95 95
     {
96
-        if (!in_array($this->level, [self::DEBUG])) {
96
+        if ( ! in_array($this->level, [self::DEBUG])) {
97 97
             return;
98 98
         }
99 99
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function error($message, array $context = [])
107 107
     {
108
-        if (!in_array($this->level, [self::DEBUG, self::INFO, self::ERROR])) {
108
+        if ( ! in_array($this->level, [self::DEBUG, self::INFO, self::ERROR])) {
109 109
             return;
110 110
         }
111 111
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         $datetime = $datetime->format(DATE_ATOM);
122 122
 
123 123
         $content = sprintf('%s -- %s -- %s -- %s', $level, $_SERVER['REMOTE_ADDR'], $datetime, $message);
124
-        $content .= ($context ? "\n" . print_r($context, true) : '');
124
+        $content .= ($context ? "\n".print_r($context, true) : '');
125 125
         $content .= "\n";
126 126
 
127 127
         file_put_contents($this->file, $content, FILE_APPEND);
Please login to merge, or discard this patch.
src/Adapter/AbstractAdapter.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
      */
301 301
     protected function setCallback($callback)
302 302
     {
303
-        if (!filter_var($callback, FILTER_VALIDATE_URL)) {
303
+        if ( ! filter_var($callback, FILTER_VALIDATE_URL)) {
304 304
             throw new InvalidArgumentException('A valid callback url is required.');
305 305
         }
306 306
 
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
      */
340 340
     protected function validateApiResponse($error = '')
341 341
     {
342
-        $error .= !empty($error) ? '. ' : '';
342
+        $error .= ! empty($error) ? '. ' : '';
343 343
 
344 344
         if ($this->httpClient->getResponseClientError()) {
345 345
             throw new HttpClientFailureException(
346
-                $error . 'HTTP client error: ' . $this->httpClient->getResponseClientError() . '.'
346
+                $error.'HTTP client error: '.$this->httpClient->getResponseClientError().'.'
347 347
             );
348 348
         }
349 349
 
350 350
         // if validateApiResponseHttpCode is set to false, we by pass verification of http status code
351
-        if (!$this->validateApiResponseHttpCode) {
351
+        if ( ! $this->validateApiResponseHttpCode) {
352 352
             return;
353 353
         }
354 354
 
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 
357 357
         if ($status < 200 || $status > 299) {
358 358
             throw new HttpRequestFailedException(
359
-                $error . 'HTTP error ' . $this->httpClient->getResponseHttpCode() .
360
-                '. Raw Provider API response: ' . $this->httpClient->getResponseBody() . '.'
359
+                $error.'HTTP error '.$this->httpClient->getResponseHttpCode().
360
+                '. Raw Provider API response: '.$this->httpClient->getResponseBody().'.'
361 361
             );
362 362
         }
363 363
     }
Please login to merge, or discard this patch.
Indentation   +345 added lines, -345 removed lines patch added patch discarded remove patch
@@ -24,349 +24,349 @@
 block discarded – undo
24 24
  */
25 25
 abstract class AbstractAdapter implements AdapterInterface
26 26
 {
27
-    use DataStoreTrait;
28
-
29
-    /**
30
-     * Provider ID (unique name).
31
-     *
32
-     * @var string
33
-     */
34
-    protected $providerId = '';
35
-
36
-    /**
37
-     * Specific Provider config.
38
-     *
39
-     * @var mixed
40
-     */
41
-    protected $config = [];
42
-
43
-    /**
44
-     * Extra Provider parameters.
45
-     *
46
-     * @var array
47
-     */
48
-    protected $params;
49
-
50
-    /**
51
-     * Callback url
52
-     *
53
-     * @var string
54
-     */
55
-    protected $callback = '';
56
-
57
-    /**
58
-     * Storage.
59
-     *
60
-     * @var StorageInterface
61
-     */
62
-    public $storage;
63
-
64
-    /**
65
-     * HttpClient.
66
-     *
67
-     * @var HttpClientInterface
68
-     */
69
-    public $httpClient;
70
-
71
-    /**
72
-     * Logger.
73
-     *
74
-     * @var LoggerInterface
75
-     */
76
-    public $logger;
77
-
78
-    /**
79
-     * Whether to validate API status codes of http responses
80
-     *
81
-     * @var bool
82
-     */
83
-    protected $validateApiResponseHttpCode = true;
84
-
85
-    /**
86
-     * Common adapters constructor.
87
-     *
88
-     * @param array $config
89
-     * @param HttpClientInterface $httpClient
90
-     * @param StorageInterface $storage
91
-     * @param LoggerInterface $logger
92
-     */
93
-    public function __construct(
94
-        $config = [],
95
-        HttpClientInterface $httpClient = null,
96
-        StorageInterface $storage = null,
97
-        LoggerInterface $logger = null
98
-    ) {
99
-        $this->providerId = (new \ReflectionClass($this))->getShortName();
100
-
101
-        $this->config = new Data\Collection($config);
102
-
103
-        $this->setHttpClient($httpClient);
104
-
105
-        $this->setStorage($storage);
106
-
107
-        $this->setLogger($logger);
108
-
109
-        $this->configure();
110
-
111
-        $this->logger->debug(sprintf('Initialize %s, config: ', get_class($this)), $config);
112
-
113
-        $this->initialize();
114
-    }
115
-
116
-    /**
117
-     * Load adapter's configuration
118
-     */
119
-    abstract protected function configure();
120
-
121
-    /**
122
-     * Adapter initializer
123
-     */
124
-    abstract protected function initialize();
125
-
126
-    /**
127
-     * {@inheritdoc}
128
-     */
129
-    abstract public function isConnected();
130
-
131
-    /**
132
-     * {@inheritdoc}
133
-     */
134
-    public function apiRequest($url, $method = 'GET', $parameters = [], $headers = [], $multipart = false)
135
-    {
136
-        throw new NotImplementedException('Provider does not support this feature.');
137
-    }
138
-
139
-    /**
140
-     * {@inheritdoc}
141
-     */
142
-    public function maintainToken()
143
-    {
144
-        // Nothing needed for most providers
145
-    }
146
-
147
-    /**
148
-     * {@inheritdoc}
149
-     */
150
-    public function getUserProfile()
151
-    {
152
-        throw new NotImplementedException('Provider does not support this feature.');
153
-    }
154
-
155
-    /**
156
-     * {@inheritdoc}
157
-     */
158
-    public function getUserContacts()
159
-    {
160
-        throw new NotImplementedException('Provider does not support this feature.');
161
-    }
162
-
163
-    /**
164
-     * {@inheritdoc}
165
-     */
166
-    public function getUserPages()
167
-    {
168
-        throw new NotImplementedException('Provider does not support this feature.');
169
-    }
170
-
171
-    /**
172
-     * {@inheritdoc}
173
-     */
174
-    public function getUserActivity($stream)
175
-    {
176
-        throw new NotImplementedException('Provider does not support this feature.');
177
-    }
178
-
179
-    /**
180
-     * {@inheritdoc}
181
-     */
182
-    public function setUserStatus($status)
183
-    {
184
-        throw new NotImplementedException('Provider does not support this feature.');
185
-    }
186
-
187
-    /**
188
-     * {@inheritdoc}
189
-     */
190
-    public function setPageStatus($status, $pageId)
191
-    {
192
-        throw new NotImplementedException('Provider does not support this feature.');
193
-    }
194
-
195
-    /**
196
-     * {@inheritdoc}
197
-     */
198
-    public function disconnect()
199
-    {
200
-        $this->clearStoredData();
201
-    }
202
-
203
-    /**
204
-     * {@inheritdoc}
205
-     */
206
-    public function getAccessToken()
207
-    {
208
-        $tokenNames = [
209
-            'access_token',
210
-            'access_token_secret',
211
-            'token_type',
212
-            'refresh_token',
213
-            'expires_in',
214
-            'expires_at',
215
-        ];
216
-
217
-        $tokens = [];
218
-
219
-        foreach ($tokenNames as $name) {
220
-            if ($this->getStoredData($name)) {
221
-                $tokens[$name] = $this->getStoredData($name);
222
-            }
223
-        }
224
-
225
-        return $tokens;
226
-    }
227
-
228
-    /**
229
-     * {@inheritdoc}
230
-     */
231
-    public function setAccessToken($tokens = [])
232
-    {
233
-        $this->clearStoredData();
234
-
235
-        foreach ($tokens as $token => $value) {
236
-            $this->storeData($token, $value);
237
-        }
238
-
239
-        // Re-initialize token parameters.
240
-        $this->initialize();
241
-    }
242
-
243
-    /**
244
-     * {@inheritdoc}
245
-     */
246
-    public function setHttpClient(HttpClientInterface $httpClient = null)
247
-    {
248
-        $this->httpClient = $httpClient ?: new HttpClient();
249
-
250
-        if ($this->config->exists('curl_options') && method_exists($this->httpClient, 'setCurlOptions')) {
251
-            $this->httpClient->setCurlOptions($this->config->get('curl_options'));
252
-        }
253
-    }
254
-
255
-    /**
256
-     * {@inheritdoc}
257
-     */
258
-    public function getHttpClient()
259
-    {
260
-        return $this->httpClient;
261
-    }
262
-
263
-    /**
264
-     * {@inheritdoc}
265
-     */
266
-    public function setStorage(StorageInterface $storage = null)
267
-    {
268
-        $this->storage = $storage ?: new Session();
269
-    }
270
-
271
-    /**
272
-     * {@inheritdoc}
273
-     */
274
-    public function getStorage()
275
-    {
276
-        return $this->storage;
277
-    }
278
-
279
-    /**
280
-     * {@inheritdoc}
281
-     */
282
-    public function setLogger(LoggerInterface $logger = null)
283
-    {
284
-        $this->logger = $logger ?: new Logger(
285
-            $this->config->get('debug_mode'),
286
-            $this->config->get('debug_file')
287
-        );
288
-
289
-        if (method_exists($this->httpClient, 'setLogger')) {
290
-            $this->httpClient->setLogger($this->logger);
291
-        }
292
-    }
293
-
294
-    /**
295
-     * {@inheritdoc}
296
-     */
297
-    public function getLogger()
298
-    {
299
-        return $this->logger;
300
-    }
301
-
302
-    /**
303
-     * Set Adapter's API callback url
304
-     *
305
-     * @param string $callback
306
-     *
307
-     * @throws InvalidArgumentException
308
-     */
309
-    protected function setCallback($callback)
310
-    {
311
-        if (!filter_var($callback, FILTER_VALIDATE_URL)) {
312
-            throw new InvalidArgumentException('A valid callback url is required.');
313
-        }
314
-
315
-        $this->callback = $callback;
316
-    }
317
-
318
-    /**
319
-     * Overwrite Adapter's API endpoints
320
-     *
321
-     * @param array|Data\Collection $endpoints
322
-     */
323
-    protected function setApiEndpoints($endpoints = null)
324
-    {
325
-        if (empty($endpoints)) {
326
-            return;
327
-        }
328
-
329
-        $collection = is_array($endpoints) ? new Data\Collection($endpoints) : $endpoints;
330
-
331
-        $this->apiBaseUrl = $collection->get('api_base_url') ?: $this->apiBaseUrl;
332
-        $this->authorizeUrl = $collection->get('authorize_url') ?: $this->authorizeUrl;
333
-        $this->accessTokenUrl = $collection->get('access_token_url') ?: $this->accessTokenUrl;
334
-    }
335
-
336
-
337
-    /**
338
-     * Validate signed API responses Http status code.
339
-     *
340
-     * Since the specifics of error responses is beyond the scope of RFC6749 and OAuth Core specifications,
341
-     * Hybridauth will consider any HTTP status code that is different than '200 OK' as an ERROR.
342
-     *
343
-     * @param string $error String to pre append to message thrown in exception
344
-     *
345
-     * @throws HttpClientFailureException
346
-     * @throws HttpRequestFailedException
347
-     */
348
-    protected function validateApiResponse($error = '')
349
-    {
350
-        $error .= !empty($error) ? '. ' : '';
351
-
352
-        if ($this->httpClient->getResponseClientError()) {
353
-            throw new HttpClientFailureException(
354
-                $error . 'HTTP client error: ' . $this->httpClient->getResponseClientError() . '.'
355
-            );
356
-        }
357
-
358
-        // if validateApiResponseHttpCode is set to false, we by pass verification of http status code
359
-        if (!$this->validateApiResponseHttpCode) {
360
-            return;
361
-        }
362
-
363
-        $status = $this->httpClient->getResponseHttpCode();
364
-
365
-        if ($status < 200 || $status > 299) {
366
-            throw new HttpRequestFailedException(
367
-                $error . 'HTTP error ' . $this->httpClient->getResponseHttpCode() .
368
-                '. Raw Provider API response: ' . $this->httpClient->getResponseBody() . '.'
369
-            );
370
-        }
371
-    }
27
+	use DataStoreTrait;
28
+
29
+	/**
30
+	 * Provider ID (unique name).
31
+	 *
32
+	 * @var string
33
+	 */
34
+	protected $providerId = '';
35
+
36
+	/**
37
+	 * Specific Provider config.
38
+	 *
39
+	 * @var mixed
40
+	 */
41
+	protected $config = [];
42
+
43
+	/**
44
+	 * Extra Provider parameters.
45
+	 *
46
+	 * @var array
47
+	 */
48
+	protected $params;
49
+
50
+	/**
51
+	 * Callback url
52
+	 *
53
+	 * @var string
54
+	 */
55
+	protected $callback = '';
56
+
57
+	/**
58
+	 * Storage.
59
+	 *
60
+	 * @var StorageInterface
61
+	 */
62
+	public $storage;
63
+
64
+	/**
65
+	 * HttpClient.
66
+	 *
67
+	 * @var HttpClientInterface
68
+	 */
69
+	public $httpClient;
70
+
71
+	/**
72
+	 * Logger.
73
+	 *
74
+	 * @var LoggerInterface
75
+	 */
76
+	public $logger;
77
+
78
+	/**
79
+	 * Whether to validate API status codes of http responses
80
+	 *
81
+	 * @var bool
82
+	 */
83
+	protected $validateApiResponseHttpCode = true;
84
+
85
+	/**
86
+	 * Common adapters constructor.
87
+	 *
88
+	 * @param array $config
89
+	 * @param HttpClientInterface $httpClient
90
+	 * @param StorageInterface $storage
91
+	 * @param LoggerInterface $logger
92
+	 */
93
+	public function __construct(
94
+		$config = [],
95
+		HttpClientInterface $httpClient = null,
96
+		StorageInterface $storage = null,
97
+		LoggerInterface $logger = null
98
+	) {
99
+		$this->providerId = (new \ReflectionClass($this))->getShortName();
100
+
101
+		$this->config = new Data\Collection($config);
102
+
103
+		$this->setHttpClient($httpClient);
104
+
105
+		$this->setStorage($storage);
106
+
107
+		$this->setLogger($logger);
108
+
109
+		$this->configure();
110
+
111
+		$this->logger->debug(sprintf('Initialize %s, config: ', get_class($this)), $config);
112
+
113
+		$this->initialize();
114
+	}
115
+
116
+	/**
117
+	 * Load adapter's configuration
118
+	 */
119
+	abstract protected function configure();
120
+
121
+	/**
122
+	 * Adapter initializer
123
+	 */
124
+	abstract protected function initialize();
125
+
126
+	/**
127
+	 * {@inheritdoc}
128
+	 */
129
+	abstract public function isConnected();
130
+
131
+	/**
132
+	 * {@inheritdoc}
133
+	 */
134
+	public function apiRequest($url, $method = 'GET', $parameters = [], $headers = [], $multipart = false)
135
+	{
136
+		throw new NotImplementedException('Provider does not support this feature.');
137
+	}
138
+
139
+	/**
140
+	 * {@inheritdoc}
141
+	 */
142
+	public function maintainToken()
143
+	{
144
+		// Nothing needed for most providers
145
+	}
146
+
147
+	/**
148
+	 * {@inheritdoc}
149
+	 */
150
+	public function getUserProfile()
151
+	{
152
+		throw new NotImplementedException('Provider does not support this feature.');
153
+	}
154
+
155
+	/**
156
+	 * {@inheritdoc}
157
+	 */
158
+	public function getUserContacts()
159
+	{
160
+		throw new NotImplementedException('Provider does not support this feature.');
161
+	}
162
+
163
+	/**
164
+	 * {@inheritdoc}
165
+	 */
166
+	public function getUserPages()
167
+	{
168
+		throw new NotImplementedException('Provider does not support this feature.');
169
+	}
170
+
171
+	/**
172
+	 * {@inheritdoc}
173
+	 */
174
+	public function getUserActivity($stream)
175
+	{
176
+		throw new NotImplementedException('Provider does not support this feature.');
177
+	}
178
+
179
+	/**
180
+	 * {@inheritdoc}
181
+	 */
182
+	public function setUserStatus($status)
183
+	{
184
+		throw new NotImplementedException('Provider does not support this feature.');
185
+	}
186
+
187
+	/**
188
+	 * {@inheritdoc}
189
+	 */
190
+	public function setPageStatus($status, $pageId)
191
+	{
192
+		throw new NotImplementedException('Provider does not support this feature.');
193
+	}
194
+
195
+	/**
196
+	 * {@inheritdoc}
197
+	 */
198
+	public function disconnect()
199
+	{
200
+		$this->clearStoredData();
201
+	}
202
+
203
+	/**
204
+	 * {@inheritdoc}
205
+	 */
206
+	public function getAccessToken()
207
+	{
208
+		$tokenNames = [
209
+			'access_token',
210
+			'access_token_secret',
211
+			'token_type',
212
+			'refresh_token',
213
+			'expires_in',
214
+			'expires_at',
215
+		];
216
+
217
+		$tokens = [];
218
+
219
+		foreach ($tokenNames as $name) {
220
+			if ($this->getStoredData($name)) {
221
+				$tokens[$name] = $this->getStoredData($name);
222
+			}
223
+		}
224
+
225
+		return $tokens;
226
+	}
227
+
228
+	/**
229
+	 * {@inheritdoc}
230
+	 */
231
+	public function setAccessToken($tokens = [])
232
+	{
233
+		$this->clearStoredData();
234
+
235
+		foreach ($tokens as $token => $value) {
236
+			$this->storeData($token, $value);
237
+		}
238
+
239
+		// Re-initialize token parameters.
240
+		$this->initialize();
241
+	}
242
+
243
+	/**
244
+	 * {@inheritdoc}
245
+	 */
246
+	public function setHttpClient(HttpClientInterface $httpClient = null)
247
+	{
248
+		$this->httpClient = $httpClient ?: new HttpClient();
249
+
250
+		if ($this->config->exists('curl_options') && method_exists($this->httpClient, 'setCurlOptions')) {
251
+			$this->httpClient->setCurlOptions($this->config->get('curl_options'));
252
+		}
253
+	}
254
+
255
+	/**
256
+	 * {@inheritdoc}
257
+	 */
258
+	public function getHttpClient()
259
+	{
260
+		return $this->httpClient;
261
+	}
262
+
263
+	/**
264
+	 * {@inheritdoc}
265
+	 */
266
+	public function setStorage(StorageInterface $storage = null)
267
+	{
268
+		$this->storage = $storage ?: new Session();
269
+	}
270
+
271
+	/**
272
+	 * {@inheritdoc}
273
+	 */
274
+	public function getStorage()
275
+	{
276
+		return $this->storage;
277
+	}
278
+
279
+	/**
280
+	 * {@inheritdoc}
281
+	 */
282
+	public function setLogger(LoggerInterface $logger = null)
283
+	{
284
+		$this->logger = $logger ?: new Logger(
285
+			$this->config->get('debug_mode'),
286
+			$this->config->get('debug_file')
287
+		);
288
+
289
+		if (method_exists($this->httpClient, 'setLogger')) {
290
+			$this->httpClient->setLogger($this->logger);
291
+		}
292
+	}
293
+
294
+	/**
295
+	 * {@inheritdoc}
296
+	 */
297
+	public function getLogger()
298
+	{
299
+		return $this->logger;
300
+	}
301
+
302
+	/**
303
+	 * Set Adapter's API callback url
304
+	 *
305
+	 * @param string $callback
306
+	 *
307
+	 * @throws InvalidArgumentException
308
+	 */
309
+	protected function setCallback($callback)
310
+	{
311
+		if (!filter_var($callback, FILTER_VALIDATE_URL)) {
312
+			throw new InvalidArgumentException('A valid callback url is required.');
313
+		}
314
+
315
+		$this->callback = $callback;
316
+	}
317
+
318
+	/**
319
+	 * Overwrite Adapter's API endpoints
320
+	 *
321
+	 * @param array|Data\Collection $endpoints
322
+	 */
323
+	protected function setApiEndpoints($endpoints = null)
324
+	{
325
+		if (empty($endpoints)) {
326
+			return;
327
+		}
328
+
329
+		$collection = is_array($endpoints) ? new Data\Collection($endpoints) : $endpoints;
330
+
331
+		$this->apiBaseUrl = $collection->get('api_base_url') ?: $this->apiBaseUrl;
332
+		$this->authorizeUrl = $collection->get('authorize_url') ?: $this->authorizeUrl;
333
+		$this->accessTokenUrl = $collection->get('access_token_url') ?: $this->accessTokenUrl;
334
+	}
335
+
336
+
337
+	/**
338
+	 * Validate signed API responses Http status code.
339
+	 *
340
+	 * Since the specifics of error responses is beyond the scope of RFC6749 and OAuth Core specifications,
341
+	 * Hybridauth will consider any HTTP status code that is different than '200 OK' as an ERROR.
342
+	 *
343
+	 * @param string $error String to pre append to message thrown in exception
344
+	 *
345
+	 * @throws HttpClientFailureException
346
+	 * @throws HttpRequestFailedException
347
+	 */
348
+	protected function validateApiResponse($error = '')
349
+	{
350
+		$error .= !empty($error) ? '. ' : '';
351
+
352
+		if ($this->httpClient->getResponseClientError()) {
353
+			throw new HttpClientFailureException(
354
+				$error . 'HTTP client error: ' . $this->httpClient->getResponseClientError() . '.'
355
+			);
356
+		}
357
+
358
+		// if validateApiResponseHttpCode is set to false, we by pass verification of http status code
359
+		if (!$this->validateApiResponseHttpCode) {
360
+			return;
361
+		}
362
+
363
+		$status = $this->httpClient->getResponseHttpCode();
364
+
365
+		if ($status < 200 || $status > 299) {
366
+			throw new HttpRequestFailedException(
367
+				$error . 'HTTP error ' . $this->httpClient->getResponseHttpCode() .
368
+				'. Raw Provider API response: ' . $this->httpClient->getResponseBody() . '.'
369
+			);
370
+		}
371
+	}
372 372
 }
Please login to merge, or discard this patch.
src/Adapter/DataStoreTrait.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -12,63 +12,63 @@
 block discarded – undo
12 12
  */
13 13
 trait DataStoreTrait
14 14
 {
15
-    /**
16
-     * Returns storage instance
17
-     *
18
-     * @return \Hybridauth\Storage\StorageInterface
19
-     */
20
-    abstract public function getStorage();
15
+	/**
16
+	 * Returns storage instance
17
+	 *
18
+	 * @return \Hybridauth\Storage\StorageInterface
19
+	 */
20
+	abstract public function getStorage();
21 21
 
22
-    /**
23
-     * Store a piece of data in storage.
24
-     *
25
-     * This method is mainly used for OAuth tokens (access, secret, refresh, and whatnot), but it
26
-     * can be also used by providers to store any other useful data (i.g., user_id, auth_nonce, etc.)
27
-     *
28
-     * @param string $name
29
-     * @param mixed $value
30
-     */
31
-    protected function storeData($name, $value = null)
32
-    {
33
-        // if empty, we simply delete the thing as we'd want to only store necessary data
34
-        if (empty($value)) {
35
-            $this->deleteStoredData($name);
36
-        }
22
+	/**
23
+	 * Store a piece of data in storage.
24
+	 *
25
+	 * This method is mainly used for OAuth tokens (access, secret, refresh, and whatnot), but it
26
+	 * can be also used by providers to store any other useful data (i.g., user_id, auth_nonce, etc.)
27
+	 *
28
+	 * @param string $name
29
+	 * @param mixed $value
30
+	 */
31
+	protected function storeData($name, $value = null)
32
+	{
33
+		// if empty, we simply delete the thing as we'd want to only store necessary data
34
+		if (empty($value)) {
35
+			$this->deleteStoredData($name);
36
+		}
37 37
 
38
-        $this->getStorage()->set($this->providerId . '.' . $name, $value);
39
-    }
38
+		$this->getStorage()->set($this->providerId . '.' . $name, $value);
39
+	}
40 40
 
41
-    /**
42
-     * Retrieve a piece of data from storage.
43
-     *
44
-     * This method is mainly used for OAuth tokens (access, secret, refresh, and whatnot), but it
45
-     * can be also used by providers to retrieve from store any other useful data (i.g., user_id,
46
-     * auth_nonce, etc.)
47
-     *
48
-     * @param string $name
49
-     *
50
-     * @return mixed
51
-     */
52
-    protected function getStoredData($name)
53
-    {
54
-        return $this->getStorage()->get($this->providerId . '.' . $name);
55
-    }
41
+	/**
42
+	 * Retrieve a piece of data from storage.
43
+	 *
44
+	 * This method is mainly used for OAuth tokens (access, secret, refresh, and whatnot), but it
45
+	 * can be also used by providers to retrieve from store any other useful data (i.g., user_id,
46
+	 * auth_nonce, etc.)
47
+	 *
48
+	 * @param string $name
49
+	 *
50
+	 * @return mixed
51
+	 */
52
+	protected function getStoredData($name)
53
+	{
54
+		return $this->getStorage()->get($this->providerId . '.' . $name);
55
+	}
56 56
 
57
-    /**
58
-     * Delete a stored piece of data.
59
-     *
60
-     * @param string $name
61
-     */
62
-    protected function deleteStoredData($name)
63
-    {
64
-        $this->getStorage()->delete($this->providerId . '.' . $name);
65
-    }
57
+	/**
58
+	 * Delete a stored piece of data.
59
+	 *
60
+	 * @param string $name
61
+	 */
62
+	protected function deleteStoredData($name)
63
+	{
64
+		$this->getStorage()->delete($this->providerId . '.' . $name);
65
+	}
66 66
 
67
-    /**
68
-     * Delete all stored data of the instantiated adapter
69
-     */
70
-    protected function clearStoredData()
71
-    {
72
-        $this->getStorage()->deleteMatch($this->providerId . '.');
73
-    }
67
+	/**
68
+	 * Delete all stored data of the instantiated adapter
69
+	 */
70
+	protected function clearStoredData()
71
+	{
72
+		$this->getStorage()->deleteMatch($this->providerId . '.');
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
             $this->deleteStoredData($name);
36 36
         }
37 37
 
38
-        $this->getStorage()->set($this->providerId . '.' . $name, $value);
38
+        $this->getStorage()->set($this->providerId.'.'.$name, $value);
39 39
     }
40 40
 
41 41
     /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     protected function getStoredData($name)
53 53
     {
54
-        return $this->getStorage()->get($this->providerId . '.' . $name);
54
+        return $this->getStorage()->get($this->providerId.'.'.$name);
55 55
     }
56 56
 
57 57
     /**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     protected function deleteStoredData($name)
63 63
     {
64
-        $this->getStorage()->delete($this->providerId . '.' . $name);
64
+        $this->getStorage()->delete($this->providerId.'.'.$name);
65 65
     }
66 66
 
67 67
     /**
@@ -69,6 +69,6 @@  discard block
 block discarded – undo
69 69
      */
70 70
     protected function clearStoredData()
71 71
     {
72
-        $this->getStorage()->deleteMatch($this->providerId . '.');
72
+        $this->getStorage()->deleteMatch($this->providerId.'.');
73 73
     }
74 74
 }
Please login to merge, or discard this patch.
src/Data/Parser.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
     {
30 30
         $data = $this->parseJson($raw);
31 31
 
32
-        if (!$data) {
32
+        if ( ! $data) {
33 33
             $data = $this->parseXml($raw);
34 34
 
35
-            if (!$data) {
35
+            if ( ! $data) {
36 36
                 $data = $this->parseQueryString($raw);
37 37
             }
38 38
         }
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 
69 69
         libxml_use_internal_errors(false);
70 70
 
71
-        if (!$xml) {
71
+        if ( ! $xml) {
72 72
             return [];
73 73
         }
74 74
 
75
-        $arr = json_decode(json_encode((array)$xml), true);
75
+        $arr = json_decode(json_encode((array) $xml), true);
76 76
         $arr = array($xml->getName() => $arr);
77 77
 
78 78
         return $arr;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     {
90 90
         parse_str($result, $output);
91 91
 
92
-        if (!is_array($output)) {
92
+        if ( ! is_array($output)) {
93 93
             return $result;
94 94
         }
95 95
 
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -15,104 +15,104 @@
 block discarded – undo
15 15
  */
16 16
 final class Parser
17 17
 {
18
-    /**
19
-     * Decodes a string into an object.
20
-     *
21
-     * This method will first attempt to parse data as a JSON string (since most providers use this format)
22
-     * then XML and parse_str.
23
-     *
24
-     * @param string $raw
25
-     *
26
-     * @return mixed
27
-     */
28
-    public function parse($raw = null)
29
-    {
30
-        $data = $this->parseJson($raw);
31
-
32
-        if (!$data) {
33
-            $data = $this->parseXml($raw);
34
-
35
-            if (!$data) {
36
-                $data = $this->parseQueryString($raw);
37
-            }
38
-        }
39
-
40
-        return $data;
41
-    }
42
-
43
-    /**
44
-     * Decodes a JSON string
45
-     *
46
-     * @param $result
47
-     *
48
-     * @return mixed
49
-     */
50
-    public function parseJson($result)
51
-    {
52
-        return json_decode($result);
53
-    }
54
-
55
-    /**
56
-     * Decodes a XML string
57
-     *
58
-     * @param $result
59
-     *
60
-     * @return mixed
61
-     */
62
-    public function parseXml($result)
63
-    {
64
-        libxml_use_internal_errors(true);
65
-
66
-        $result = preg_replace('/([<\/])([a-z0-9-]+):/i', '$1', $result);
67
-        $xml = simplexml_load_string($result);
68
-
69
-        libxml_use_internal_errors(false);
70
-
71
-        if (!$xml) {
72
-            return [];
73
-        }
74
-
75
-        $arr = json_decode(json_encode((array)$xml), true);
76
-        $arr = array($xml->getName() => $arr);
77
-
78
-        return $arr;
79
-    }
80
-
81
-    /**
82
-     * Parses a string into variables
83
-     *
84
-     * @param $result
85
-     *
86
-     * @return \StdClass
87
-     */
88
-    public function parseQueryString($result)
89
-    {
90
-        parse_str($result, $output);
91
-
92
-        if (!is_array($output)) {
93
-            return $result;
94
-        }
95
-
96
-        $result = new \StdClass();
97
-
98
-        foreach ($output as $k => $v) {
99
-            $result->$k = $v;
100
-        }
101
-
102
-        return $result;
103
-    }
104
-
105
-    /**
106
-     * needs to be improved
107
-     *
108
-     * @param $birthday
109
-     *
110
-     * @return array
111
-     */
112
-    public function parseBirthday($birthday)
113
-    {
114
-        $birthday = date_parse((string) $birthday);
115
-
116
-        return [$birthday['year'], $birthday['month'], $birthday['day']];
117
-    }
18
+	/**
19
+	 * Decodes a string into an object.
20
+	 *
21
+	 * This method will first attempt to parse data as a JSON string (since most providers use this format)
22
+	 * then XML and parse_str.
23
+	 *
24
+	 * @param string $raw
25
+	 *
26
+	 * @return mixed
27
+	 */
28
+	public function parse($raw = null)
29
+	{
30
+		$data = $this->parseJson($raw);
31
+
32
+		if (!$data) {
33
+			$data = $this->parseXml($raw);
34
+
35
+			if (!$data) {
36
+				$data = $this->parseQueryString($raw);
37
+			}
38
+		}
39
+
40
+		return $data;
41
+	}
42
+
43
+	/**
44
+	 * Decodes a JSON string
45
+	 *
46
+	 * @param $result
47
+	 *
48
+	 * @return mixed
49
+	 */
50
+	public function parseJson($result)
51
+	{
52
+		return json_decode($result);
53
+	}
54
+
55
+	/**
56
+	 * Decodes a XML string
57
+	 *
58
+	 * @param $result
59
+	 *
60
+	 * @return mixed
61
+	 */
62
+	public function parseXml($result)
63
+	{
64
+		libxml_use_internal_errors(true);
65
+
66
+		$result = preg_replace('/([<\/])([a-z0-9-]+):/i', '$1', $result);
67
+		$xml = simplexml_load_string($result);
68
+
69
+		libxml_use_internal_errors(false);
70
+
71
+		if (!$xml) {
72
+			return [];
73
+		}
74
+
75
+		$arr = json_decode(json_encode((array)$xml), true);
76
+		$arr = array($xml->getName() => $arr);
77
+
78
+		return $arr;
79
+	}
80
+
81
+	/**
82
+	 * Parses a string into variables
83
+	 *
84
+	 * @param $result
85
+	 *
86
+	 * @return \StdClass
87
+	 */
88
+	public function parseQueryString($result)
89
+	{
90
+		parse_str($result, $output);
91
+
92
+		if (!is_array($output)) {
93
+			return $result;
94
+		}
95
+
96
+		$result = new \StdClass();
97
+
98
+		foreach ($output as $k => $v) {
99
+			$result->$k = $v;
100
+		}
101
+
102
+		return $result;
103
+	}
104
+
105
+	/**
106
+	 * needs to be improved
107
+	 *
108
+	 * @param $birthday
109
+	 *
110
+	 * @return array
111
+	 */
112
+	public function parseBirthday($birthday)
113
+	{
114
+		$birthday = date_parse((string) $birthday);
115
+
116
+		return [$birthday['year'], $birthday['month'], $birthday['day']];
117
+	}
118 118
 }
Please login to merge, or discard this patch.
src/HttpClient/Guzzle.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function request($uri, $method = 'GET', $parameters = [], $headers = [], $multipart = false)
115 115
     {
116
-        $this->requestHeader = array_replace($this->requestHeader, (array)$headers);
116
+        $this->requestHeader = array_replace($this->requestHeader, (array) $headers);
117 117
 
118 118
         $this->requestArguments = [
119 119
             'uri' => $uri,
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             $this->responseClientError = $e->getMessage();
171 171
         }
172 172
 
173
-        if (!$this->responseClientError) {
173
+        if ( ! $this->responseClientError) {
174 174
             $this->responseBody = $response->getBody();
175 175
             $this->responseHttpCode = $response->getStatusCode();
176 176
             $this->responseHeader = $response->getHeaders();
Please login to merge, or discard this patch.
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -33,244 +33,244 @@
 block discarded – undo
33 33
  */
34 34
 class Guzzle implements HttpClientInterface
35 35
 {
36
-    /**
37
-     * Method request() arguments
38
-     *
39
-     * This is used for debugging.
40
-     *
41
-     * @var array
42
-     */
43
-    protected $requestArguments = [];
44
-
45
-    /**
46
-     * Default request headers
47
-     *
48
-     * @var array
49
-     */
50
-    protected $requestHeader = [];
51
-
52
-    /**
53
-     * Raw response returned by server
54
-     *
55
-     * @var string
56
-     */
57
-    protected $responseBody = '';
58
-
59
-    /**
60
-     * Headers returned in the response
61
-     *
62
-     * @var array
63
-     */
64
-    protected $responseHeader = [];
65
-
66
-    /**
67
-     * Response HTTP status code
68
-     *
69
-     * @var int
70
-     */
71
-    protected $responseHttpCode = 0;
72
-
73
-    /**
74
-     * Last curl error number
75
-     *
76
-     * @var mixed
77
-     */
78
-    protected $responseClientError = null;
79
-
80
-    /**
81
-     * Information about the last transfer
82
-     *
83
-     * @var mixed
84
-     */
85
-    protected $responseClientInfo = [];
86
-
87
-    /**
88
-     * Hybridauth logger instance
89
-     *
90
-     * @var object
91
-     */
92
-    protected $logger = null;
93
-
94
-    /**
95
-     * GuzzleHttp client
96
-     *
97
-     * @var \GuzzleHttp\Client
98
-     */
99
-    protected $client = null;
100
-
101
-    /**
102
-     * ..
103
-     * @param null $client
104
-     * @param array $config
105
-     */
106
-    public function __construct($client = null, $config = [])
107
-    {
108
-        $this->client = $client ? $client : new Client($config);
109
-    }
110
-
111
-    /**
112
-     * {@inheritdoc}
113
-     */
114
-    public function request($uri, $method = 'GET', $parameters = [], $headers = [], $multipart = false)
115
-    {
116
-        $this->requestHeader = array_replace($this->requestHeader, (array)$headers);
117
-
118
-        $this->requestArguments = [
119
-            'uri' => $uri,
120
-            'method' => $method,
121
-            'parameters' => $parameters,
122
-            'headers' => $this->requestHeader,
123
-        ];
124
-
125
-        $response = null;
126
-
127
-        try {
128
-            switch ($method) {
129
-                case 'GET':
130
-                case 'DELETE':
131
-                    $response = $this->client->request($method, $uri, [
132
-                        'query' => $parameters,
133
-                        'headers' => $this->requestHeader,
134
-                    ]);
135
-                    break;
136
-                case 'PUT':
137
-                case 'PATCH':
138
-                case 'POST':
139
-                    $body_type = $multipart ? 'multipart' : 'form_params';
140
-
141
-                    if (isset($this->requestHeader['Content-Type'])
142
-                        && $this->requestHeader['Content-Type'] === 'application/json'
143
-                    ) {
144
-                        $body_type = 'json';
145
-                    }
146
-
147
-                    $body_content = $parameters;
148
-                    if ($multipart) {
149
-                        $body_content = [];
150
-                        foreach ($parameters as $key => $val) {
151
-                            if ($val instanceof \CURLFile) {
152
-                                $val = fopen($val->getFilename(), 'r');
153
-                            }
154
-
155
-                            $body_content[] = [
156
-                                'name' => $key,
157
-                                'contents' => $val,
158
-                            ];
159
-                        }
160
-                    }
161
-
162
-                    $response = $this->client->request($method, $uri, [
163
-                        $body_type => $body_content,
164
-                        'headers' => $this->requestHeader,
165
-                    ]);
166
-                    break;
167
-            }
168
-        } catch (\Exception $e) {
169
-            $response = $e->getResponse();
170
-
171
-            $this->responseClientError = $e->getMessage();
172
-        }
173
-
174
-        if (!$this->responseClientError) {
175
-            $this->responseBody = $response->getBody();
176
-            $this->responseHttpCode = $response->getStatusCode();
177
-            $this->responseHeader = $response->getHeaders();
178
-        }
179
-
180
-        if ($this->logger) {
181
-            // phpcs:ignore
182
-            $this->logger->debug(sprintf('%s::request( %s, %s ), response:', get_class($this), $uri, $method), $this->getResponse());
183
-
184
-            if ($this->responseClientError) {
185
-                // phpcs:ignore
186
-                $this->logger->error(sprintf('%s::request( %s, %s ), error:', get_class($this), $uri, $method), [$this->responseClientError]);
187
-            }
188
-        }
189
-
190
-        return $this->responseBody;
191
-    }
192
-
193
-    /**
194
-     * Get response details
195
-     *
196
-     * @return array Map structure of details
197
-     */
198
-    public function getResponse()
199
-    {
200
-        return [
201
-            'request' => $this->getRequestArguments(),
202
-            'response' => [
203
-                'code' => $this->getResponseHttpCode(),
204
-                'headers' => $this->getResponseHeader(),
205
-                'body' => $this->getResponseBody(),
206
-            ],
207
-            'client' => [
208
-                'error' => $this->getResponseClientError(),
209
-                'info' => $this->getResponseClientInfo(),
210
-                'opts' => null,
211
-            ],
212
-        ];
213
-    }
214
-
215
-    /**
216
-     * Set logger instance
217
-     *
218
-     * @param object $logger
219
-     */
220
-    public function setLogger($logger)
221
-    {
222
-        $this->logger = $logger;
223
-    }
224
-
225
-    /**
226
-     * {@inheritdoc}
227
-     */
228
-    public function getResponseBody()
229
-    {
230
-        return $this->responseBody;
231
-    }
232
-
233
-    /**
234
-     * {@inheritdoc}
235
-     */
236
-    public function getResponseHeader()
237
-    {
238
-        return $this->responseHeader;
239
-    }
240
-
241
-    /**
242
-     * {@inheritdoc}
243
-     */
244
-    public function getResponseHttpCode()
245
-    {
246
-        return $this->responseHttpCode;
247
-    }
248
-
249
-    /**
250
-     * {@inheritdoc}
251
-     */
252
-    public function getResponseClientError()
253
-    {
254
-        return $this->responseClientError;
255
-    }
256
-
257
-    /**
258
-     * @return array
259
-     */
260
-    protected function getResponseClientInfo()
261
-    {
262
-        return $this->responseClientInfo;
263
-    }
264
-
265
-    /**
266
-     * Returns method request() arguments
267
-     *
268
-     * This is used for debugging.
269
-     *
270
-     * @return array
271
-     */
272
-    protected function getRequestArguments()
273
-    {
274
-        return $this->requestArguments;
275
-    }
36
+	/**
37
+	 * Method request() arguments
38
+	 *
39
+	 * This is used for debugging.
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $requestArguments = [];
44
+
45
+	/**
46
+	 * Default request headers
47
+	 *
48
+	 * @var array
49
+	 */
50
+	protected $requestHeader = [];
51
+
52
+	/**
53
+	 * Raw response returned by server
54
+	 *
55
+	 * @var string
56
+	 */
57
+	protected $responseBody = '';
58
+
59
+	/**
60
+	 * Headers returned in the response
61
+	 *
62
+	 * @var array
63
+	 */
64
+	protected $responseHeader = [];
65
+
66
+	/**
67
+	 * Response HTTP status code
68
+	 *
69
+	 * @var int
70
+	 */
71
+	protected $responseHttpCode = 0;
72
+
73
+	/**
74
+	 * Last curl error number
75
+	 *
76
+	 * @var mixed
77
+	 */
78
+	protected $responseClientError = null;
79
+
80
+	/**
81
+	 * Information about the last transfer
82
+	 *
83
+	 * @var mixed
84
+	 */
85
+	protected $responseClientInfo = [];
86
+
87
+	/**
88
+	 * Hybridauth logger instance
89
+	 *
90
+	 * @var object
91
+	 */
92
+	protected $logger = null;
93
+
94
+	/**
95
+	 * GuzzleHttp client
96
+	 *
97
+	 * @var \GuzzleHttp\Client
98
+	 */
99
+	protected $client = null;
100
+
101
+	/**
102
+	 * ..
103
+	 * @param null $client
104
+	 * @param array $config
105
+	 */
106
+	public function __construct($client = null, $config = [])
107
+	{
108
+		$this->client = $client ? $client : new Client($config);
109
+	}
110
+
111
+	/**
112
+	 * {@inheritdoc}
113
+	 */
114
+	public function request($uri, $method = 'GET', $parameters = [], $headers = [], $multipart = false)
115
+	{
116
+		$this->requestHeader = array_replace($this->requestHeader, (array)$headers);
117
+
118
+		$this->requestArguments = [
119
+			'uri' => $uri,
120
+			'method' => $method,
121
+			'parameters' => $parameters,
122
+			'headers' => $this->requestHeader,
123
+		];
124
+
125
+		$response = null;
126
+
127
+		try {
128
+			switch ($method) {
129
+				case 'GET':
130
+				case 'DELETE':
131
+					$response = $this->client->request($method, $uri, [
132
+						'query' => $parameters,
133
+						'headers' => $this->requestHeader,
134
+					]);
135
+					break;
136
+				case 'PUT':
137
+				case 'PATCH':
138
+				case 'POST':
139
+					$body_type = $multipart ? 'multipart' : 'form_params';
140
+
141
+					if (isset($this->requestHeader['Content-Type'])
142
+						&& $this->requestHeader['Content-Type'] === 'application/json'
143
+					) {
144
+						$body_type = 'json';
145
+					}
146
+
147
+					$body_content = $parameters;
148
+					if ($multipart) {
149
+						$body_content = [];
150
+						foreach ($parameters as $key => $val) {
151
+							if ($val instanceof \CURLFile) {
152
+								$val = fopen($val->getFilename(), 'r');
153
+							}
154
+
155
+							$body_content[] = [
156
+								'name' => $key,
157
+								'contents' => $val,
158
+							];
159
+						}
160
+					}
161
+
162
+					$response = $this->client->request($method, $uri, [
163
+						$body_type => $body_content,
164
+						'headers' => $this->requestHeader,
165
+					]);
166
+					break;
167
+			}
168
+		} catch (\Exception $e) {
169
+			$response = $e->getResponse();
170
+
171
+			$this->responseClientError = $e->getMessage();
172
+		}
173
+
174
+		if (!$this->responseClientError) {
175
+			$this->responseBody = $response->getBody();
176
+			$this->responseHttpCode = $response->getStatusCode();
177
+			$this->responseHeader = $response->getHeaders();
178
+		}
179
+
180
+		if ($this->logger) {
181
+			// phpcs:ignore
182
+			$this->logger->debug(sprintf('%s::request( %s, %s ), response:', get_class($this), $uri, $method), $this->getResponse());
183
+
184
+			if ($this->responseClientError) {
185
+				// phpcs:ignore
186
+				$this->logger->error(sprintf('%s::request( %s, %s ), error:', get_class($this), $uri, $method), [$this->responseClientError]);
187
+			}
188
+		}
189
+
190
+		return $this->responseBody;
191
+	}
192
+
193
+	/**
194
+	 * Get response details
195
+	 *
196
+	 * @return array Map structure of details
197
+	 */
198
+	public function getResponse()
199
+	{
200
+		return [
201
+			'request' => $this->getRequestArguments(),
202
+			'response' => [
203
+				'code' => $this->getResponseHttpCode(),
204
+				'headers' => $this->getResponseHeader(),
205
+				'body' => $this->getResponseBody(),
206
+			],
207
+			'client' => [
208
+				'error' => $this->getResponseClientError(),
209
+				'info' => $this->getResponseClientInfo(),
210
+				'opts' => null,
211
+			],
212
+		];
213
+	}
214
+
215
+	/**
216
+	 * Set logger instance
217
+	 *
218
+	 * @param object $logger
219
+	 */
220
+	public function setLogger($logger)
221
+	{
222
+		$this->logger = $logger;
223
+	}
224
+
225
+	/**
226
+	 * {@inheritdoc}
227
+	 */
228
+	public function getResponseBody()
229
+	{
230
+		return $this->responseBody;
231
+	}
232
+
233
+	/**
234
+	 * {@inheritdoc}
235
+	 */
236
+	public function getResponseHeader()
237
+	{
238
+		return $this->responseHeader;
239
+	}
240
+
241
+	/**
242
+	 * {@inheritdoc}
243
+	 */
244
+	public function getResponseHttpCode()
245
+	{
246
+		return $this->responseHttpCode;
247
+	}
248
+
249
+	/**
250
+	 * {@inheritdoc}
251
+	 */
252
+	public function getResponseClientError()
253
+	{
254
+		return $this->responseClientError;
255
+	}
256
+
257
+	/**
258
+	 * @return array
259
+	 */
260
+	protected function getResponseClientInfo()
261
+	{
262
+		return $this->responseClientInfo;
263
+	}
264
+
265
+	/**
266
+	 * Returns method request() arguments
267
+	 *
268
+	 * This is used for debugging.
269
+	 *
270
+	 * @return array
271
+	 */
272
+	protected function getRequestArguments()
273
+	{
274
+		return $this->requestArguments;
275
+	}
276 276
 }
Please login to merge, or discard this patch.