subscription instanceof Id ? $this->repo->ofId($cmd->subscription) : $cmd->subscription; $ws = $sub->getWorkspace(); $sub->end(); $activeSub = $ws->getSubscription(); if ( !$activeSub || (string) $activeSub->getId()->getValue() !== (string) $sub->getId()->getValue() ) { return; } if ($this->defaultPlanId) { $plan = $this->prepo->ofId(new Id($this->defaultPlanId)); $sub = new SubscriptionEntity( $ws, $plan->getSnapshot() ); $ws->subscribe($sub); } else { $ws->removeSubscription(); } } }