Skip to content

Commit

Permalink
rebuild project helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
rigonlucas committed Aug 22, 2024
1 parent 4a7170a commit b274008
Show file tree
Hide file tree
Showing 43 changed files with 119 additions and 93 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/V1/User/CreateUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
use Core\Application\User\Commons\Gateways\UserCommandInterface;
use Core\Application\User\Commons\Gateways\UserRepositoryInterface;
use Core\Application\User\Create\Inputs\CreateUserInput;
use Core\Generics\Exceptions\OutputErrorException;
use Core\Presentation\Http\Errors\ErrorPresenter;
use Core\Presentation\Http\User\UserPresenter;
use Core\Services\Framework\Contracts\TransactionManagerContract;
use Core\Services\Framework\FrameworkContract;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Exceptions\OutputErrorException;
use Core\Support\Http\ResponseStatusCodeEnum;
use Infra\Handlers\UseCases\User\Create\CreateUserHandler;

class CreateUserController extends Controller
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/V1/User/ShowUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use App\Http\Controllers\Controller;
use Core\Application\User\Show\ShowUserUseCase;
use Core\Generics\Exceptions\OutputErrorException;
use Core\Presentation\Http\Errors\ErrorPresenter;
use Core\Presentation\Http\User\UserDetaisPresenter;
use Core\Services\Framework\FrameworkContract;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Exceptions\OutputErrorException;
use Core\Support\Http\ResponseStatusCodeEnum;
use Infra\Database\User\Repository\UserRepository;

class ShowUserController extends Controller
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/V1/User/UpdateUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Core\Application\User\Commons\Gateways\UserCommandInterface;
use Core\Application\User\Commons\Gateways\UserRepositoryInterface;
use Core\Application\User\Update\Inputs\UpdateUserInput;
use Core\Generics\Exceptions\OutputErrorException;
use Core\Presentation\Http\Errors\ErrorPresenter;
use Core\Presentation\Http\User\UserPresenter;
use Core\Services\Framework\FrameworkContract;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Exceptions\OutputErrorException;
use Core\Support\Http\ResponseStatusCodeEnum;
use Infra\Handlers\UseCases\User\Update\UpdateUserHandler;
use Ramsey\Uuid\Uuid;

Expand Down
1 change: 1 addition & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private function registerDataBaseBinds(): void
$this->app->bind(TransactionManagerContract::class, TransactionManagerAdapter::class);
$this->app->bind(AuthContract::class, AuthAdapter::class);
$this->app->bind(UuidContract::class, UuidAdapter::class);
$this->app->bind(StrContract::class, StrAdapter::class);

$this->app->bind(UserCommandInterface::class, UserCommand::class);
$this->app->bind(UserRepositoryInterface::class, UserRepository::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Core\Application\Account\Commons\Exceptions;

use Core\Generics\Exceptions\OutputErrorException;
use Core\Support\Exceptions\OutputErrorException;

class AccountJoinCodeInvalidException extends OutputErrorException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Core\Application\Account\Commons\Exceptions;

use Core\Generics\Exceptions\OutputErrorException;
use Core\Support\Exceptions\OutputErrorException;

class AccountNameInvalidException extends OutputErrorException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Core\Application\Account\Commons\Exceptions;

use Core\Generics\Exceptions\OutputErrorException;
use Core\Support\Exceptions\OutputErrorException;

class AccountNotFoundException extends OutputErrorException
{
Expand Down
4 changes: 2 additions & 2 deletions core/Application/Account/Create/CreateAccountUseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Core\Domain\Entities\Account\AccountEntity;
use Core\Domain\Entities\User\UserEntity;
use Core\Services\Framework\FrameworkContract;
use Core\Support\ErrorBagValidation\HasErrorBagTrait;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Http\ResponseStatusCodeEnum;
use Core\Support\Validations\HasErrorBagTrait;

class CreateAccountUseCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Core\Application\User\Commons\Exceptions;

use Core\Generics\Exceptions\OutputErrorException;
use Core\Support\Exceptions\OutputErrorException;

class UserNotFountException extends OutputErrorException
{
Expand Down
4 changes: 2 additions & 2 deletions core/Application/User/Create/CreateUserUseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Core\Application\User\Commons\Gateways\UserRepositoryInterface;
use Core\Application\User\Create\Inputs\CreateUserInput;
use Core\Domain\Entities\User\UserEntity;
use Core\Generics\Exceptions\OutputErrorException;
use Core\Services\Framework\FrameworkContract;
use Core\Support\ErrorBagValidation\HasErrorBagTrait;
use Core\Support\Exceptions\OutputErrorException;
use Core\Support\Validations\HasErrorBagTrait;

class CreateUserUseCase
{
Expand Down
2 changes: 1 addition & 1 deletion core/Application/User/Show/ShowUserUseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Core\Application\User\Commons\Gateways\UserRepositoryInterface;
use Core\Domain\Entities\User\UserEntity;
use Core\Services\Framework\FrameworkContract;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Http\ResponseStatusCodeEnum;

class ShowUserUseCase
{
Expand Down
6 changes: 3 additions & 3 deletions core/Application/User/Update/UpdateUserUseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use Core\Application\User\Commons\Gateways\UserRepositoryInterface;
use Core\Application\User\Update\Inputs\UpdateUserInput;
use Core\Domain\Entities\User\UserEntity;
use Core\Generics\Exceptions\OutputErrorException;
use Core\Services\Framework\FrameworkContract;
use Core\Support\ErrorBagValidation\HasErrorBagTrait;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Exceptions\OutputErrorException;
use Core\Support\Http\ResponseStatusCodeEnum;
use Core\Support\Validations\HasErrorBagTrait;

class UpdateUserUseCase
{
Expand Down
2 changes: 1 addition & 1 deletion core/Domain/Entities/Account/AccountEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Core\Domain\Entities\Account\Traits\Account\AccountEntityAcessors;
use Core\Domain\Entities\Account\Traits\Account\AccountEntityBuilder;
use Core\Domain\Entities\User\UserEntity;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Http\ResponseStatusCodeEnum;

class AccountEntity
{
Expand Down
2 changes: 1 addition & 1 deletion core/Domain/Entities/Account/AccountJoinCodeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Core\Application\Account\Commons\Exceptions\AccountJoinCodeInvalidException;
use Core\Domain\Entities\Account\Traits\JoinCode\AccountJoinCodeAccessors;
use Core\Domain\Entities\Account\Traits\JoinCode\AccountJoinCodeBuilder;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Http\ResponseStatusCodeEnum;
use DateTime;
use DateTimeInterface;

Expand Down
2 changes: 1 addition & 1 deletion core/Domain/Entities/User/Traits/HasUserEntityBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Core\Domain\Entities\Account\AccountEntity;
use Core\Domain\Entities\User\UserEntity;
use Core\Domain\ValueObjects\EmailValueObject;
use Core\Generics\Exceptions\InvalidEmailException;
use Core\Support\Exceptions\InvalidEmailException;
use DateTimeInterface;
use Ramsey\Uuid\UuidInterface;
use SensitiveParameter;
Expand Down
2 changes: 1 addition & 1 deletion core/Domain/Entities/User/Traits/UserEntityAcessors.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Core\Domain\Entities\Account\AccountEntity;
use Core\Domain\ValueObjects\EmailValueObject;
use Core\Generics\Exceptions\InvalidEmailException;
use Core\Support\Exceptions\InvalidEmailException;
use DateTimeInterface;
use Ramsey\Uuid\UuidInterface;
use SensitiveParameter;
Expand Down
4 changes: 2 additions & 2 deletions core/Domain/ValueObjects/EmailValueObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Core\Domain\ValueObjects;

use Core\Generics\Exceptions\InvalidEmailException;
use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Exceptions\InvalidEmailException;
use Core\Support\Http\ResponseStatusCodeEnum;

class EmailValueObject
{
Expand Down
2 changes: 1 addition & 1 deletion core/Presentation/Http/Errors/ErrorPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Core\Presentation\Http\Errors;

use Core\Generics\Presenters\ToArrayPresenter;
use Core\Support\Presentation\ToArrayPresenter;

readonly class ErrorPresenter implements ToArrayPresenter
{
Expand Down
10 changes: 10 additions & 0 deletions core/Services/Framework/Contracts/StrContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Core\Services\Framework\Contracts;

interface StrContract
{
public function random(int $length = 16): string;

public function title(string $value): string;
}
3 changes: 3 additions & 0 deletions core/Services/Framework/FrameworkContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Core\Services\Framework;

use Core\Services\Framework\Contracts\AuthContract;
use Core\Services\Framework\Contracts\StrContract;
use Core\Services\Framework\Contracts\TransactionManagerContract;
use Core\Services\Framework\Contracts\UuidContract;

Expand All @@ -21,4 +22,6 @@ public function transactionManager(): TransactionManagerContract;
public function isDevelopeMode(): bool;

public function passwordHash(string $password): string;

public function Str(): StrContract;
}
10 changes: 0 additions & 10 deletions core/Support/ErrorBagValidation/HasErrorsInBagException.php

This file was deleted.

8 changes: 8 additions & 0 deletions core/Support/Exceptions/HasErrorsInBagException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Core\Support\Exceptions;

class HasErrorsInBagException extends OutputErrorException
{

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Core\Generics\Exceptions;
namespace Core\Support\Exceptions;

class InvalidEmailException extends OutputErrorException
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Core\Generics\Exceptions;
namespace Core\Support\Exceptions;

use Exception;

Expand Down
17 changes: 17 additions & 0 deletions core/Support/HasSingletonTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Core\Support;

trait HasSingletonTrait
{
private static ?self $instance = null;

public static function getInstance(): self
{
if (self::$instance === null) {
self::$instance = new self();
}

return self::$instance;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Core\Tools\Http;
namespace Core\Support\Http;

class HttpApiHeaders
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Core\Tools\Http;
namespace Core\Support\Http;

enum ResponseStatusCodeEnum: int
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Core\Generics\Presenters;
namespace Core\Support\Presentation;

interface PresenterWithDataAttribute
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Core\Generics\Presenters;
namespace Core\Support\Presentation;

interface ToArrayPresenter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Core\Support\ErrorBagValidation;
namespace Core\Support\Validations;

use Core\Tools\Http\ResponseStatusCodeEnum;
use Core\Support\Exceptions\HasErrorsInBagException;
use Core\Support\Http\ResponseStatusCodeEnum;

trait HasErrorBagTrait
{
Expand Down
2 changes: 1 addition & 1 deletion infra/Handlers/UseCases/User/Create/CreateUserHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use Core\Application\User\Commons\Gateways\UserRepositoryInterface;
use Core\Application\User\Create\CreateUserUseCase;
use Core\Application\User\Create\Inputs\CreateUserInput;
use Core\Generics\Exceptions\OutputErrorException;
use Core\Services\Framework\FrameworkContract;
use Core\Support\Exceptions\OutputErrorException;

readonly class CreateUserHandler
{
Expand Down
2 changes: 1 addition & 1 deletion infra/Handlers/UseCases/User/Update/UpdateUserHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use Core\Application\User\Commons\Gateways\UserRepositoryInterface;
use Core\Application\User\Update\Inputs\UpdateUserInput;
use Core\Application\User\Update\UpdateUserUseCase;
use Core\Generics\Exceptions\OutputErrorException;
use Core\Services\Framework\FrameworkContract;
use Core\Support\Exceptions\OutputErrorException;

class UpdateUserHandler
{
Expand Down
12 changes: 2 additions & 10 deletions infra/Services/Framework/Adapters/AuthAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@
namespace Infra\Services\Framework\Adapters;

use Core\Services\Framework\Contracts\AuthContract;
use Core\Support\HasSingletonTrait;

class AuthAdapter implements AuthContract
{
private static ?AuthAdapter $instance = null;

public static function getInstance(): AuthAdapter
{
if (self::$instance === null) {
self::$instance = new AuthAdapter();
}

return self::$instance;
}
use HasSingletonTrait;

public function login(string $email, string $password): void
{
Expand Down
22 changes: 22 additions & 0 deletions infra/Services/Framework/Adapters/StrAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Infra\Services\Framework\Adapters;

use Core\Services\Framework\Contracts\StrContract;
use Core\Support\HasSingletonTrait;
use Illuminate\Support\Str;

class StrAdapter implements StrContract
{
use HasSingletonTrait;

public function random(int $length = 16): string
{
return Str::random($length);
}

public function title(string $value): string
{
return Str::title($value);
}
}
Loading

0 comments on commit b274008

Please sign in to comment.