Version 0.7.0 #1

Merged
kor-elf merged 90 commits from develop into main 2023-12-08 21:18:23 +06:00
3 changed files with 20 additions and 4 deletions
Showing only changes of commit 91810190b7 - Show all commits

View File

@ -0,0 +1,15 @@
<?php declare(strict_types=1);
namespace App\ServiceResults;
final class ServiceResultSuccess extends ServiceResult
{
public function __construct(
private readonly string $message
) { }
public function getMessage(): string
{
return $this->message;
}
}

View File

@ -4,8 +4,8 @@ namespace App\Services;
use App\Dto\Request\Authorization;
use App\Repositories\UserRepository;
use App\ServiceResults\ServiceResultArray;
use App\ServiceResults\ServiceResultError;
use App\ServiceResults\ServiceResultSuccess;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
@ -15,7 +15,7 @@ final class AuthService extends Service
private readonly UserRepository $userRepository
) { }
public function authorization(Authorization $authorization): ServiceResultError | ServiceResultArray
public function authorization(Authorization $authorization): ServiceResultError | ServiceResultSuccess
{
$user = $this->userRepository->getUserByEmail($authorization->getEmail());
if (is_null($user)) {

View File

@ -5,6 +5,7 @@ namespace App\Services;
use App\ServiceResults\ServiceResultArray;
use App\ServiceResults\ServiceResultError;
use App\ServiceResults\ServiceResultSuccess;
use Illuminate\Http\Response;
abstract class Service
@ -39,9 +40,9 @@ abstract class Service
return $this->error(Response::HTTP_UNAUTHORIZED, $message);
}
final protected function ok(string $message = 'OK'): ServiceResultArray
final protected function ok(string $message = 'OK'): ServiceResultSuccess
{
return $this->result(['message' => $message]);
return new ServiceResultSuccess($message);
}
final protected function result(array $data = []): ServiceResultArray