/** * Register a plan with the manager. * * @param Plan $plan * * @throws PlanKeyMustBeUnique */ private function registerPlan(Plan $plan) { if ($this->find($plan->getKey())) { throw new PlanKeyMustBeUnique(sprintf('The key "%s" is already bound to the manager.', $plan->getKey())); } array_push($this->plans, $plan); }
/** * Remove a plan from the manager for the current request. * * @param string|\EdwardNelson\PlanManager\Plan $plan */ public function removePlan($plan) { $key = $plan instanceof Plan ? $plan->getKey() : $plan; foreach ($this->plans as $array_key => $plan) { if ($plan->getKey() == $key) { unset($this->plans[$array_key]); break; } } }