Updated coding standards
This commit is contained in:
parent
dcf4e948e7
commit
65c08825a5
|
@ -89,12 +89,12 @@ abstract class OAuth2
|
|||
|
||||
/**
|
||||
* @param $scope
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function addScope(string $scope):OAuth2
|
||||
{
|
||||
// Add a scope to the scopes array if it isn't already present
|
||||
// Add a scope to the scopes array if it isn't already present
|
||||
if (!\in_array($scope, $this->scopes)) {
|
||||
$this->scopes[] = $scope;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class Apple extends OAuth2
|
|||
* @var array
|
||||
*/
|
||||
protected $scopes = [
|
||||
"name",
|
||||
"name",
|
||||
"email"
|
||||
];
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class Facebook extends OAuth2
|
|||
'redirect_uri' => $this->callback,
|
||||
'client_secret' => $this->appSecret,
|
||||
'code' => $code
|
||||
])
|
||||
])
|
||||
);
|
||||
|
||||
$accessToken = \json_decode($accessToken, true);
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Appwrite\Auth\OAuth2;
|
|||
|
||||
use Appwrite\Auth\OAuth2;
|
||||
|
||||
// Reference Material
|
||||
// Reference Material
|
||||
// https://docs.gitlab.com/ee/api/oauth2.html
|
||||
|
||||
class Gitlab extends OAuth2
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Appwrite\Auth\OAuth2;
|
|||
|
||||
use Appwrite\Auth\OAuth2;
|
||||
|
||||
// Reference Material
|
||||
// Reference Material
|
||||
// https://developers.google.com/oauthplayground/
|
||||
// https://developers.google.com/identity/protocols/OAuth2
|
||||
// https://developers.google.com/identity/protocols/OAuth2WebServer
|
||||
|
|
|
@ -19,7 +19,7 @@ class Microsoft extends OAuth2
|
|||
* @var array
|
||||
*/
|
||||
protected $scopes = [
|
||||
'offline_access',
|
||||
'offline_access',
|
||||
'user.read'
|
||||
];
|
||||
|
||||
|
|
|
@ -134,4 +134,4 @@ class Mock extends OAuth2
|
|||
|
||||
return $this->user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ class Slack extends OAuth2
|
|||
* @var array
|
||||
*/
|
||||
protected $scopes = [
|
||||
'identity.avatar',
|
||||
'identity.basic',
|
||||
'identity.avatar',
|
||||
'identity.basic',
|
||||
'identity.email',
|
||||
'identity.team'
|
||||
];
|
||||
|
|
|
@ -137,8 +137,11 @@ class Spotify extends OAuth2
|
|||
protected function getUser(string $accessToken)
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
$this->user = \json_decode($this->request('GET',
|
||||
$this->resourceEndpoint . "me", ['Authorization: Bearer '.\urlencode($accessToken)]), true);
|
||||
$this->user = \json_decode($this->request(
|
||||
'GET',
|
||||
$this->resourceEndpoint . "me",
|
||||
['Authorization: Bearer '.\urlencode($accessToken)]
|
||||
), true);
|
||||
}
|
||||
|
||||
return $this->user;
|
||||
|
|
|
@ -139,8 +139,11 @@ class Twitch extends OAuth2
|
|||
protected function getUser(string $accessToken)
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
$this->user = \json_decode($this->request('GET',
|
||||
$this->resourceEndpoint, ['Authorization: Bearer '.\urlencode($accessToken)]), true)['data']['0'];
|
||||
$this->user = \json_decode($this->request(
|
||||
'GET',
|
||||
$this->resourceEndpoint,
|
||||
['Authorization: Bearer '.\urlencode($accessToken)]
|
||||
), true)['data']['0'];
|
||||
}
|
||||
|
||||
return $this->user;
|
||||
|
|
|
@ -153,8 +153,11 @@ class Yahoo extends OAuth2
|
|||
protected function getUser(string $accessToken)
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
$this->user = \json_decode($this->request('GET',
|
||||
$this->resourceEndpoint, ['Authorization: Bearer '.\urlencode($accessToken)]), true);
|
||||
$this->user = \json_decode($this->request(
|
||||
'GET',
|
||||
$this->resourceEndpoint,
|
||||
['Authorization: Bearer '.\urlencode($accessToken)]
|
||||
), true);
|
||||
}
|
||||
|
||||
return $this->user;
|
||||
|
|
|
@ -111,7 +111,7 @@ class Authorization extends Validator
|
|||
/**
|
||||
* Default value in case we need
|
||||
* to reset Authorization status
|
||||
*
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $statusDefault = true;
|
||||
|
@ -119,7 +119,7 @@ class Authorization extends Validator
|
|||
/**
|
||||
* Change default status.
|
||||
* This will be used for the
|
||||
* value set on the self::reset() method
|
||||
* value set on the self::reset() method
|
||||
*/
|
||||
public static function setDefaultStatus($status)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ class CNAME extends Validator
|
|||
|
||||
/**
|
||||
* Check if CNAME record target value matches selected target
|
||||
*
|
||||
*
|
||||
* @param string $domain
|
||||
*
|
||||
* @return bool
|
||||
|
|
|
@ -92,7 +92,7 @@ class Origin extends Validator
|
|||
/**
|
||||
* Check if Origin has been whiltlisted
|
||||
* for access to the API
|
||||
*
|
||||
*
|
||||
* @param string $origin
|
||||
*
|
||||
* @return bool
|
||||
|
|
|
@ -78,7 +78,7 @@ class Storage
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function human($bytes, $decimals = 2)
|
||||
public static function human($bytes, $decimals = 2)
|
||||
{
|
||||
$units = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
|
||||
$step = 1024;
|
||||
|
|
|
@ -6,14 +6,14 @@ class URL
|
|||
{
|
||||
/**
|
||||
* Parse URL
|
||||
*
|
||||
*
|
||||
* Take a URL string and split it to array parts
|
||||
*
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function parse(string $url):array
|
||||
public static function parse(string $url):array
|
||||
{
|
||||
$default = [
|
||||
'scheme' => '',
|
||||
|
@ -31,15 +31,15 @@ class URL
|
|||
|
||||
/**
|
||||
* Un-Parse URL
|
||||
*
|
||||
*
|
||||
* Take URL parts and combine them to a valid string
|
||||
*
|
||||
*
|
||||
* @param array $url
|
||||
* @param array $ommit
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
static public function unparse(array $url, array $ommit = []):string
|
||||
public static function unparse(array $url, array $ommit = []):string
|
||||
{
|
||||
if (isset($url['path']) && \mb_substr($url['path'], 0, 1) !== '/') {
|
||||
$url['path'] = '/'.$url['path'];
|
||||
|
@ -78,14 +78,14 @@ class URL
|
|||
|
||||
/**
|
||||
* Parse Query String
|
||||
*
|
||||
*
|
||||
* Convert query string to array
|
||||
*
|
||||
*
|
||||
* @param string $query
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function parseQuery(string $query):array
|
||||
public static function parseQuery(string $query):array
|
||||
{
|
||||
\parse_str($query, $result);
|
||||
|
||||
|
@ -94,15 +94,15 @@ class URL
|
|||
|
||||
/**
|
||||
* Un-Parse Query String
|
||||
*
|
||||
*
|
||||
* Convert query string array to string
|
||||
*
|
||||
*
|
||||
* @param string $query
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
static public function unparseQuery(array $query):string
|
||||
public static function unparseQuery(array $query):string
|
||||
{
|
||||
return \http_build_query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue