Code cleanup

This commit is contained in:
James Cole
2018-04-02 14:50:17 +02:00
parent 379b104778
commit fa7ab45a40
100 changed files with 440 additions and 517 deletions

View File

@@ -77,8 +77,8 @@ class UserRepository implements UserRepositoryInterface
Preferences::setForUser($user, 'previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);
// set undo and confirm token:
Preferences::setForUser($user, 'email_change_undo_token', strval(bin2hex(random_bytes(16))));
Preferences::setForUser($user, 'email_change_confirm_token', strval(bin2hex(random_bytes(16))));
Preferences::setForUser($user, 'email_change_undo_token', (string)bin2hex(random_bytes(16)));
Preferences::setForUser($user, 'email_change_confirm_token', (string)bin2hex(random_bytes(16)));
// update user
$user->email = $newEmail;
@@ -145,7 +145,7 @@ class UserRepository implements UserRepositoryInterface
*
* @return bool
*
* @throws \Exception
*/
public function destroy(User $user): bool
{
@@ -231,7 +231,7 @@ class UserRepository implements UserRepositoryInterface
}
$return['is_admin'] = $user->hasRole('owner');
$return['blocked'] = 1 === intval($user->blocked);
$return['blocked'] = 1 === (int)$user->blocked;
$return['blocked_code'] = $user->blocked_code;
$return['accounts'] = $user->accounts()->count();
$return['journals'] = $user->transactionJournals()->count();

View File

@@ -103,17 +103,12 @@ interface UserRepositoryInterface
/**
* @param int $userId
*
* @deprecated
* @return User
*/
public function find(int $userId): User;
/**
* @param int $userId
* @return User|null
*/
public function findNull(int $userId): ?User;
/**
* @param string $email
*
@@ -121,6 +116,13 @@ interface UserRepositoryInterface
*/
public function findByEmail(string $email): ?User;
/**
* @param int $userId
*
* @return User|null
*/
public function findNull(int $userId): ?User;
/**
* Returns the first user in the DB. Generally only works when there is just one.
*