From ad27e5bfd121c10b2b07f58dd83ac9184aef9f6a Mon Sep 17 00:00:00 2001 From: hazim Date: Thu, 7 Mar 2019 17:18:31 +0800 Subject: [PATCH] update contact recode and clean up --- .../Contacts/CreateContactLogic.php | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/app/Classes/Modules/ControllersLogic/Contacts/CreateContactLogic.php b/app/Classes/Modules/ControllersLogic/Contacts/CreateContactLogic.php index 165ccb5..2adeda4 100644 --- a/app/Classes/Modules/ControllersLogic/Contacts/CreateContactLogic.php +++ b/app/Classes/Modules/ControllersLogic/Contacts/CreateContactLogic.php @@ -2,41 +2,38 @@ namespace App\Modules\ControllerLogic\Contacts; - use App\Classes\Constants; +use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject; use App\Classes\Modules\Contacts\Exceptions\CannotCreateContactException; -use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException; -use App\Modules\Contacts\DataTransferObjects\ContactObject; -use App\Modules\Contacts\Services\CreatesContact; +use App\Classes\Modules\Contacts\Services\CreatesContact; use Illuminate\Http\Request; class CreateContactLogic { - - /** @var CreatesContact */ - private $createsContact; + /** @var CreatesContact */ + private $createContact; /** * CreateContactLogic constructor. - * @param CreatesContact $createsContact + * @param CreatesContact $createContact */ - public function __construct(CreatesContact $createsContact) + public function __construct(CreatesContact $createContact) { - $this->createsContact = $createsContact; + $this->createContact = $createContact; } - public function execute(int $type, int $referenceId, Request $request){ + public function execute(string $type, int $referenceId, Request $request) + { + try{ - try { - $object = new ContactObject($type, $referenceId, $request->input('name'), $request->input('designation'), $request->input('contact'), $request->input('email')); + $object = new ContactObject($request->input('name'), $request->input('designation'), $request->input('contact'), $request->input('email')); + return $this->createContact->execute($object, $type, $referenceId); - return $this->createsContact->execute($object); - } catch (CannotCreateContactException $exception){ + } + catch (CannotCreateContactException $exception){ throw new InternalServerErrorException("Failed to create contact because {$exception->getMessage()}"); } - - } } \ No newline at end of file