PHP CS fixer
This commit is contained in:
parent
38b472aa83
commit
e411590cf6
|
@ -99,7 +99,7 @@ abstract class OAuth
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers[] = "Content-length: ".strlen($payload);
|
$headers[] = 'Content-length: '.strlen($payload);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
// Send the request & save response to $response
|
// Send the request & save response to $response
|
||||||
|
|
|
@ -24,11 +24,11 @@ class Gitlab extends OAuth
|
||||||
*/
|
*/
|
||||||
public function getLoginURL(): string
|
public function getLoginURL(): string
|
||||||
{
|
{
|
||||||
return 'https://gitlab.com/oauth/authorize?' .
|
return 'https://gitlab.com/oauth/authorize?'.
|
||||||
'client_id=' . urlencode($this->appID) .
|
'client_id='.urlencode($this->appID).
|
||||||
'&redirect_uri=' . urlencode($this->callback) .
|
'&redirect_uri='.urlencode($this->callback).
|
||||||
'&scope=read_user' .
|
'&scope=read_user'.
|
||||||
'&state=' . urlencode(json_encode($this->state)) .
|
'&state='.urlencode(json_encode($this->state)).
|
||||||
'&response_type=code';
|
'&response_type=code';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ class Gitlab extends OAuth
|
||||||
$accessToken = $this->request(
|
$accessToken = $this->request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://gitlab.com/oauth/token?'.
|
'https://gitlab.com/oauth/token?'.
|
||||||
'code=' . urlencode($code) .
|
'code='.urlencode($code).
|
||||||
'&client_id=' . urlencode($this->appID) .
|
'&client_id='.urlencode($this->appID).
|
||||||
'&client_secret=' . urlencode($this->appSecret) .
|
'&client_secret='.urlencode($this->appSecret).
|
||||||
'&redirect_uri=' . urlencode($this->callback) .
|
'&redirect_uri='.urlencode($this->callback).
|
||||||
'&grant_type=authorization_code'
|
'&grant_type=authorization_code'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ class Gitlab extends OAuth
|
||||||
return $accessToken['access_token'];
|
return $accessToken['access_token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,9 +114,10 @@ class Gitlab extends OAuth
|
||||||
protected function getUser(string $accessToken): array
|
protected function getUser(string $accessToken): array
|
||||||
{
|
{
|
||||||
if (empty($this->user)) {
|
if (empty($this->user)) {
|
||||||
$user = $this->request('GET', 'https://gitlab.com/api/v4/user?access_token=' . urlencode($accessToken));
|
$user = $this->request('GET', 'https://gitlab.com/api/v4/user?access_token='.urlencode($accessToken));
|
||||||
$this->user = json_decode($user, true);
|
$this->user = json_decode($user, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,11 @@ class Google extends OAuth
|
||||||
*/
|
*/
|
||||||
public function getLoginURL(): string
|
public function getLoginURL(): string
|
||||||
{
|
{
|
||||||
return 'https://accounts.google.com/o/oauth2/v2/auth?' .
|
return 'https://accounts.google.com/o/oauth2/v2/auth?'.
|
||||||
'client_id=' . urlencode($this->appID) .
|
'client_id='.urlencode($this->appID).
|
||||||
'&redirect_uri=' . urlencode($this->callback) .
|
'&redirect_uri='.urlencode($this->callback).
|
||||||
'&scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile' .
|
'&scope=https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile'.
|
||||||
'&state=' . urlencode(json_encode($this->state)) .
|
'&state='.urlencode(json_encode($this->state)).
|
||||||
'&response_type=code';
|
'&response_type=code';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ class Google extends OAuth
|
||||||
{
|
{
|
||||||
$accessToken = $this->request(
|
$accessToken = $this->request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://www.googleapis.com/oauth2/' . $this->version . '/token?' .
|
'https://www.googleapis.com/oauth2/'.$this->version.'/token?'.
|
||||||
'code=' . urlencode($code) .
|
'code='.urlencode($code).
|
||||||
'&client_id=' . urlencode($this->appID) .
|
'&client_id='.urlencode($this->appID).
|
||||||
'&client_secret=' . urlencode($this->appSecret) .
|
'&client_secret='.urlencode($this->appSecret).
|
||||||
'&redirect_uri=' . urlencode($this->callback) .
|
'&redirect_uri='.urlencode($this->callback).
|
||||||
'&scope=' .
|
'&scope='.
|
||||||
'&grant_type=authorization_code'
|
'&grant_type=authorization_code'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -119,9 +119,10 @@ class Google extends OAuth
|
||||||
protected function getUser(string $accessToken): array
|
protected function getUser(string $accessToken): array
|
||||||
{
|
{
|
||||||
if (empty($this->user)) {
|
if (empty($this->user)) {
|
||||||
$user = $this->request('GET', 'https://www.googleapis.com/oauth2/v2/userinfo?access_token=' . urlencode($accessToken));
|
$user = $this->request('GET', 'https://www.googleapis.com/oauth2/v2/userinfo?access_token='.urlencode($accessToken));
|
||||||
$this->user = json_decode($user, true);
|
$this->user = json_decode($user, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->user;
|
return $this->user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Collection extends Structure
|
||||||
$document = new Document(
|
$document = new Document(
|
||||||
array_merge($this->merge, ($document instanceof Document) ? $document->getArrayCopy() : $document)
|
array_merge($this->merge, ($document instanceof Document) ? $document->getArrayCopy() : $document)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (is_null($document->getCollection())) {
|
if (is_null($document->getCollection())) {
|
||||||
$this->message = 'Missing collection attribute $collection';
|
$this->message = 'Missing collection attribute $collection';
|
||||||
|
|
||||||
|
|
|
@ -186,18 +186,19 @@ class Structure extends Validator
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($validator)) { // Error creating validator for property
|
if (empty($validator)) { // Error creating validator for property
|
||||||
$this->message = 'Unknown rule type "' . $ruleType . '" for property "' . htmlspecialchars($key, ENT_QUOTES, 'UTF-8') . '"';
|
$this->message = 'Unknown rule type "'.$ruleType.'" for property "'.htmlspecialchars($key, ENT_QUOTES, 'UTF-8').'"';
|
||||||
|
|
||||||
if (empty($ruleType)) {
|
if (empty($ruleType)) {
|
||||||
$this->message = 'Unknown property "'.$key.'" type'.
|
$this->message = 'Unknown property "'.$key.'" type'.
|
||||||
'. Make sure to follow '.strtolower($collection->getAttribute('name', 'unknown')).' collection structure';
|
'. Make sure to follow '.strtolower($collection->getAttribute('name', 'unknown')).' collection structure';
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ruleRequired && ('' === $value || null === $value)) {
|
if ($ruleRequired && ('' === $value || null === $value)) {
|
||||||
$this->message = 'Required property "'.$key.'" has no value';
|
$this->message = 'Required property "'.$key.'" has no value';
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +212,7 @@ class Structure extends Validator
|
||||||
if ($ruleArray) { // Array of values validation
|
if ($ruleArray) { // Array of values validation
|
||||||
if (!is_array($value)) {
|
if (!is_array($value)) {
|
||||||
$this->message = 'Property "'.$key.'" must be an array';
|
$this->message = 'Property "'.$key.'" must be an array';
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,12 +221,14 @@ class Structure extends Validator
|
||||||
foreach ($value as $node) {
|
foreach ($value as $node) {
|
||||||
if (!$validator->isValid($node)) { // Check if property is valid, if not required can also be empty
|
if (!$validator->isValid($node)) { // Check if property is valid, if not required can also be empty
|
||||||
$this->message = 'Property "'.$key.'" has invalid input. '.$validator->getDescription();
|
$this->message = 'Property "'.$key.'" has invalid input. '.$validator->getDescription();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // Single value validation
|
} else { // Single value validation
|
||||||
if ((!$validator->isValid($value)) && !('' === $value && !$ruleRequired)) { // Error when value is not valid, and is not optional and empty
|
if ((!$validator->isValid($value)) && !('' === $value && !$ruleRequired)) { // Error when value is not valid, and is not optional and empty
|
||||||
$this->message = 'Property "'.$key.'" has invalid input. '.$validator->getDescription();
|
$this->message = 'Property "'.$key.'" has invalid input. '.$validator->getDescription();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue