1
0
Fork 0
mirror of synced 2024-06-18 18:54:55 +12:00

Fixed coding standards

This commit is contained in:
Eldad Fux 2020-06-25 00:02:27 +03:00
parent e89004c7f4
commit dcf4e948e7
13 changed files with 33 additions and 34 deletions

View file

@ -44,7 +44,7 @@ abstract class OAuth2
$this->appSecret = $appSecret;
$this->callback = $callback;
$this->state = $state;
foreach($scopes as $scope) {
foreach ($scopes as $scope) {
$this->addScope($scope);
}
}
@ -95,15 +95,15 @@ abstract class OAuth2
protected function addScope(string $scope):OAuth2
{
// Add a scope to the scopes array if it isn't already present
if (!\in_array($scope, $this->scopes)){
$this->scopes[] = $scope;
if (!\in_array($scope, $this->scopes)) {
$this->scopes[] = $scope;
}
return $this;
}
/**
* @return array
*/
/**
* @return array
*/
protected function getScopes():array
{
return $this->scopes;

View file

@ -166,7 +166,9 @@ class Apple extends OAuth2
$success = \openssl_sign($payload, $signature, $pkey, OPENSSL_ALGO_SHA256);
if (!$success) return '';
if (!$success) {
return '';
}
return $payload.'.'.$this->encode($this->fromDER($signature, 64));
}
@ -205,8 +207,7 @@ class Apple extends OAuth2
if ('81' === \mb_substr($hex, 2, 2, '8bit')) { // LENGTH > 128
$hex = \mb_substr($hex, 6, null, '8bit');
}
else {
} else {
$hex = \mb_substr($hex, 4, null, '8bit');
}
if ('02' !== \mb_substr($hex, 0, 2, '8bit')) { // INTEGER

View file

@ -37,7 +37,6 @@ class Github extends OAuth2
'scope' => \implode(' ', $this->getScopes()),
'state' => \json_encode($this->state)
]);
}
/**

View file

@ -125,7 +125,6 @@ class Slack extends OAuth2
*/
protected function getUser(string $accessToken):array
{
if (empty($this->user)) {
// https://api.slack.com/methods/users.identity
$user = $this->request(

View file

@ -175,7 +175,7 @@ class MySQL extends Adapter
$result = $st->fetch();
if($result && isset($result['signature'])) {
if ($result && isset($result['signature'])) {
$oldSignature = $result['signature'];
if ($signature === $oldSignature) {
@ -187,14 +187,14 @@ class MySQL extends Adapter
/**
* Check Unique Keys
*/
foreach($unique as $key => $value) {
foreach ($unique as $key => $value) {
$st = $this->getPDO()->prepare('INSERT INTO `'.$this->getNamespace().'.database.unique`
SET `key` = :key;
');
$st->bindValue(':key', \md5($data['$collection'].':'.$key.'='.$value), PDO::PARAM_STR);
if(!$st->execute()) {
if (!$st->execute()) {
throw new Duplicate('Duplicated Property: '.$key.'='.$value);
}
}

View file

@ -134,7 +134,7 @@ class Document extends ArrayObject
*/
public function removeAttribute($key)
{
if(isset($this[$key])) {
if (isset($this[$key])) {
unset($this[$key]);
}

View file

@ -121,7 +121,8 @@ class Authorization extends Validator
* This will be used for the
* value set on the self::reset() method
*/
public static function setDefaultStatus($status) {
public static function setDefaultStatus($status)
{
self::$statusDefault = $status;
self::$status = $status;
}

View file

@ -60,19 +60,19 @@ class DocumentId extends Validator
{
$document = $this->database->getDocument($id);
if(!$document) {
if (!$document) {
return false;
}
if(!$document instanceof Document) {
if (!$document instanceof Document) {
return false;
}
if(!$document->getId()) {
if (!$document->getId()) {
return false;
}
if($document->getCollection() !== $this->collection) {
if ($document->getCollection() !== $this->collection) {
return false;
}

View file

@ -34,7 +34,7 @@ class Key extends Validator
*/
public function isValid($value)
{
if(!\is_string($value)) {
if (!\is_string($value)) {
return false;
}

View file

@ -39,12 +39,12 @@ class CNAME extends Validator
return false;
}
if(!$records || !\is_array($records)) {
if (!$records || !\is_array($records)) {
return false;
}
foreach($records as $record) {
if(isset($record['target']) && $record['target'] === $this->target) {
foreach ($records as $record) {
if (isset($record['target']) && $record['target'] === $this->target) {
return true;
}
}

View file

@ -56,7 +56,7 @@ class Origin extends Validator
*/
public function __construct($platforms)
{
foreach($platforms as $platform) {
foreach ($platforms as $platform) {
$type = (isset($platform['type'])) ? $platform['type'] : '';
switch ($type) {
@ -81,7 +81,7 @@ class Origin extends Validator
public function getDescription()
{
if(!\array_key_exists($this->client, $this->platforms)) {
if (!\array_key_exists($this->client, $this->platforms)) {
return 'Unsupported platform';
}
@ -105,11 +105,11 @@ class Origin extends Validator
$this->host = $host;
$this->client = $scheme;
if(empty($host)) {
if (empty($host)) {
return true;
}
if(\in_array($host, $this->clients)) {
if (\in_array($host, $this->clients)) {
return true;
}

View file

@ -157,16 +157,15 @@ class Local extends Device
*/
public function delete(string $path, bool $recursive = false):bool
{
if(\is_dir($path) && $recursive) {
if (\is_dir($path) && $recursive) {
$files = \glob($path.'*', GLOB_MARK); // GLOB_MARK adds a slash to directories returned
foreach($files as $file) {
$this->delete($file, true);
foreach ($files as $file) {
$this->delete($file, true);
}
\rmdir($path);
}
elseif(\is_file($path)) {
} elseif (\is_file($path)) {
return \unlink($path);
}

View file

@ -64,7 +64,7 @@ class FileType extends Validator
*/
public function isValid($path)
{
if(!\is_readable($path)) {
if (!\is_readable($path)) {
return false;
}