mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 20:44:19 +00:00
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Contacts\Processors;
|
|
|
|
use App\Classes\General\Interfaces\Contactable;
|
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
use App\Classes\Modules\Contacts\Services\CreatesContact;
|
|
use App\Classes\Modules\Contacts\Standards\Rules\CanCreateContact;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CreateContactProcessor
|
|
{
|
|
|
|
/** @var CanCreateContact */
|
|
private $canCreateContact;
|
|
|
|
/** @var CreatesContact */
|
|
private $createsContact;
|
|
|
|
/**
|
|
* CreateContactProcessor constructor.
|
|
* @param CanCreateContact $canCreateContact
|
|
* @param CreatesContact $createsContact
|
|
*/
|
|
public function __construct(CanCreateContact $canCreateContact, CreatesContact $createsContact)
|
|
{
|
|
$this->canCreateContact = $canCreateContact;
|
|
$this->createsContact = $createsContact;
|
|
}
|
|
|
|
/**
|
|
* @param ContactObject $object
|
|
* @param Contactable $contactable
|
|
* @return Model
|
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
public function execute(ContactObject $object, Contactable $contactable): Model
|
|
{
|
|
|
|
$this->canCreateContact->passes($object);
|
|
|
|
return $this->createsContact->execute($contactable,$object);
|
|
}
|
|
}
|