1
0
Fork 0
mirror of synced 2024-05-20 20:52:36 +12:00

Updated coding standards

This commit is contained in:
Eldad Fux 2020-06-25 00:05:16 +03:00
parent dcf4e948e7
commit 65c08825a5
16 changed files with 47 additions and 38 deletions

View file

@ -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;
}

View file

@ -19,7 +19,7 @@ class Apple extends OAuth2
* @var array
*/
protected $scopes = [
"name",
"name",
"email"
];

View file

@ -58,7 +58,7 @@ class Facebook extends OAuth2
'redirect_uri' => $this->callback,
'client_secret' => $this->appSecret,
'code' => $code
])
])
);
$accessToken = \json_decode($accessToken, true);

View file

@ -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

View file

@ -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

View file

@ -19,7 +19,7 @@ class Microsoft extends OAuth2
* @var array
*/
protected $scopes = [
'offline_access',
'offline_access',
'user.read'
];

View file

@ -134,4 +134,4 @@ class Mock extends OAuth2
return $this->user;
}
}
}

View file

@ -15,8 +15,8 @@ class Slack extends OAuth2
* @var array
*/
protected $scopes = [
'identity.avatar',
'identity.basic',
'identity.avatar',
'identity.basic',
'identity.email',
'identity.team'
];

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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)
{

View file

@ -26,7 +26,7 @@ class CNAME extends Validator
/**
* Check if CNAME record target value matches selected target
*
*
* @param string $domain
*
* @return bool

View file

@ -92,7 +92,7 @@ class Origin extends Validator
/**
* Check if Origin has been whiltlisted
* for access to the API
*
*
* @param string $origin
*
* @return bool

View file

@ -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;

View file

@ -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);
}
}
}