workspace instanceof WorkspaceEntity ? $cmd->workspace : $this->wsRepo->ofId($cmd->workspace); $user = $cmd->user instanceof UserEntity ? $cmd->user : $this->userRepo->ofId($cmd->user); if ( !is_null($ws->getTotalCreditCount()->value) && (float) $ws->getTotalCreditCount()->value <= 0 ) { throw new InsufficientCreditsException(); } $entity = new ConversationEntity( $ws, $user ); $this->repo->add($entity); return $entity; } }