canAssignSegment = $canAssignSegment; $this->assignsCompanyConnectionToConnectionSegment = $assignsCompanyConnectionToConnectionSegment; $this->fetchesSegment = $fetchesSegment; } /** * @param CompanyConnection $companyConnection * @param int|null $segmentId * @return Model * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\MalformedRequestException * @throws \App\Classes\Exceptions\RequestValidationException */ public function execute(CompanyConnection $companyConnection, ?int $segmentId = SegmentConstants::STANDARD_SEGMENT): Model { $segment = $this->fetchesSegment->execute(['id' => $segmentId]); $this->canAssignSegment->passes(); return $this->assignsCompanyConnectionToConnectionSegment->execute($companyConnection, $segment); } }