move dto from constructor to method paramour

in create carrier use case
This commit is contained in:
Yisroel Baum 2025-11-18 09:15:40 +02:00
parent 18e43b3bac
commit 908baee2a7
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 10 additions and 11 deletions

View file

@ -8,21 +8,20 @@ use FreightQuote\Carrier\CarrierRepository;
class CreateCarrier class CreateCarrier
{ {
public function __construct( public function __construct(
private CreateCarrierRequest $dto,
private CarrierRepository $carrierRepo, private CarrierRepository $carrierRepo,
) {} ) {}
public function execute(): Carrier public function execute(CreateCarrierRequest $dto): Carrier
{ {
$carrier = new Carrier( $carrier = new Carrier(
null, null,
$this->dto->email, $dto->email,
$this->dto->companyName, $dto->companyName,
$this->dto->contactPerson, $dto->contactPerson,
$this->dto->phoneNumber, $dto->phoneNumber,
$this->dto->notes, $dto->notes,
$this->dto->loadProfile, $dto->loadProfile,
$this->dto->countriesServing, $dto->countriesServing,
[], [],
); );

View file

@ -28,8 +28,8 @@ class CreateCarrierTest extends TestCase
$loadProfile, $loadProfile,
$countriesServing, $countriesServing,
); );
$useCase = new CreateCarrier($dto, $carrierRepo); $useCase = new CreateCarrier($carrierRepo);
$response = $useCase->execute(); $response = $useCase->execute($dto);
$foundCarrier = $carrierRepo->find($response->getId()); $foundCarrier = $carrierRepo->find($response->getId());
$this->assertEquals($email, $foundCarrier->getEmail()); $this->assertEquals($email, $foundCarrier->getEmail());
$this->assertEquals($company, $foundCarrier->getCompanyName()); $this->assertEquals($company, $foundCarrier->getCompanyName());