refactor: code style changes

Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
2023-01-15 00:04:00 +00:00
parent 25155bff2e
commit 3727c84f3e
146 changed files with 1013 additions and 1341 deletions

View File

@@ -1,33 +1,29 @@
<?php
namespace App\Services;
use App\Exceptions\ProfileAlreadyExistsException;
use App\Exceptions\ProfileCreationFailedException;
use App\Exceptions\ProfileNotFoundException;
use App\Profile;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
class ProfileService
{
/**
* Creates a new profile for the specified $targetUser.
*
* @param User $targetUser The user to create the profile for.
* @param User $targetUser The user to create the profile for.
* @return bool
*
* @throws ProfileAlreadyExistsException
* @throws ProfileCreationFailedException
*/
public function createProfile(User $targetUser): Profile {
public function createProfile(User $targetUser): Profile
{
if (is_null($targetUser->profile)) {
$profile = Profile::create([
'profileShortBio' => 'Write a one-liner about you here!',
@@ -42,7 +38,7 @@ class ProfileService
}
Log::info('Created profile for new user', [
'userid' => $targetUser->id
'userid' => $targetUser->id,
]);
return $profile;
@@ -56,7 +52,8 @@ class ProfileService
*
* @throws ProfileNotFoundException
*/
public function updateProfile($userID, Request $request) {
public function updateProfile($userID, Request $request)
{
$profile = User::find($userID)->profile;
$social = [];
@@ -85,23 +82,22 @@ class ProfileService
return $profile->save();
}
throw new ProfileNotFoundException("This profile does not exist.");
throw new ProfileNotFoundException('This profile does not exist.');
}
/**
* Delete specified user's profile
*
* @param User $targetUser
* @param User $targetUser
* @return bool
*
* @throws ProfileNotFoundException
*/
public function deleteProfile(User $targetUser): bool
{
if (!is_null($targetUser->profile)) {
if (! is_null($targetUser->profile)) {
Log::alert('Deleted user profile', [
'userid' => $targetUser->id
'userid' => $targetUser->id,
]);
return $targetUser->profile->delete();
@@ -109,5 +105,4 @@ class ProfileService
throw new ProfileNotFoundException(__('Attempting to delete non-existant profile!'));
}
}