/** * @param $name * * @return \MetaborStd\Statemachine\StateInterface * * @throws \Exception */ public function findOrCreateState($name) { if (!$this->stateCollection->hasState($name)) { if ($this->stateCollection instanceof StateCollection) { $this->stateCollection->addState($this->createState($name)); } else { throw new \InvalidArgumentException('Overwrite this method to implement a different type!'); } } return $this->stateCollection->getState($name); }
/** * @param string $name * * @return \MetaborStd\Statemachine\StateInterface */ protected function findOrCreateState($name) { $name = $this->stateNamePrefix . $name; if ($this->targetCollection->hasState($name)) { $targetState = $this->targetCollection->getState($name); } else { $targetState = $this->createState($name); $this->addState($targetState); } return $targetState; }