Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed May 5, 2021
1 parent b4bdfa9 commit 9f409fe
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions lib/Slave.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace OCA\GlobalSiteSelector;


use Exception;
use OCA\GlobalSiteSelector\AppInfo\Application;
use OCP\Accounts\IAccountManager;
use OCP\Http\Client\IClientService;
Expand Down Expand Up @@ -68,12 +68,13 @@ class Slave {
/** @var IConfig */
private $config;

public function __construct(IAccountManager $accountManager,
IUserManager $userManager,
IClientService $clientService,
GlobalSiteSelector $gss,
LoggerInterface $logger,
IConfig $config
public function __construct(
IAccountManager $accountManager,
IUserManager $userManager,
IClientService $clientService,
GlobalSiteSelector $gss,
LoggerInterface $logger,
IConfig $config
) {
$this->accountManager = $accountManager;
$this->userManager = $userManager;
Expand All @@ -88,8 +89,8 @@ public function __construct(IAccountManager $accountManager,
$this->config = $config;
}

public function createUser(array $params) {
if ($this->checkConfiguration() === false) {
public function createUser(array $params): void {
if ($this->checkConfiguration() === false) {
return;
}

Expand All @@ -115,8 +116,8 @@ public function createUser(array $params) {
*
* @param IUser $user
*/
public function updateUser(IUser $user) {
if ($this->checkConfiguration() === false) {
public function updateUser(IUser $user): void {
if ($this->checkConfiguration() === false) {
return;
}

Expand All @@ -139,7 +140,7 @@ public function updateUser(IUser $user) {
*
* @param array $params
*/
public function preDeleteUser(array $params) {
public function preDeleteUser(array $params): void {
$uid = $params['uid'];
$user = $this->userManager->get($uid);
if ($user !== null) {
Expand All @@ -152,8 +153,8 @@ public function preDeleteUser(array $params) {
*
* @param array $params
*/
public function deleteUser(array $params) {
if ($this->checkConfiguration() === false) {
public function deleteUser(array $params): void {
if ($this->checkConfiguration() === false) {
return;
}

Expand All @@ -176,8 +177,8 @@ public function deleteUser(array $params) {
* update the lookup server with all known users on this instance. This
* is triggered by a cronjob
*/
public function batchUpdate() {
if ($this->checkConfiguration() === false) {
public function batchUpdate(): void {
if ($this->checkConfiguration() === false) {
return;
}

Expand Down Expand Up @@ -206,7 +207,7 @@ public function batchUpdate() {
* @param IUser $user
* @return array
*/
protected function getAccountData(IUser $user) {
protected function getAccountData(IUser $user): array {
$rawData = $this->accountManager->getAccount($user);
$data = [];
foreach ($rawData as $key => $value) {
Expand All @@ -227,7 +228,7 @@ protected function getAccountData(IUser $user) {
*
* @param array $users
*/
protected function addUsers(array $users) {
protected function addUsers(array $users): void {
$dataBatch = ['authKey' => $this->authKey, 'users' => $users];

$this->logger->debug('Batch updating users: {users}',
Expand All @@ -246,7 +247,7 @@ protected function addUsers(array $users) {
'connect_timeout' => 3,
]
);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->logger->warning('Could not send user to lookup server',
[
'app' => Application::APP_ID,
Expand All @@ -261,7 +262,7 @@ protected function addUsers(array $users) {
*
* @param array $users
*/
protected function removeUsers(array $users) {
protected function removeUsers(array $users): void {
$dataBatch = ['authKey' => $this->authKey, 'users' => $users];

$this->logger->debug('Batch deleting users: {users}',
Expand All @@ -280,7 +281,7 @@ protected function removeUsers(array $users) {
'connect_timeout' => 3,
]
);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->logger->warning('Could not remove user from the lookup server',
[
'app' => Application::APP_ID,
Expand All @@ -290,7 +291,7 @@ protected function removeUsers(array $users) {
}
}

protected function checkConfiguration() {
protected function checkConfiguration(): bool {
if (empty($this->lookupServer)
|| empty($this->operationMode)
|| empty($this->authKey)
Expand All @@ -302,21 +303,21 @@ protected function checkConfiguration() {
);
return false;
}
return true;
}

/**
* Operation mode - slave or master
* @return string
*/
public function getOperationMode() {
public function getOperationMode(): string {
return $this->operationMode;
}

/**
* send user back to master
*/
public function handleLogoutRequest() {

$token = ['logout' => 'true',
'exp' => time() + 300, // expires after 5 minute
];
Expand Down

0 comments on commit 9f409fe

Please sign in to comment.