Add an available state
@param StateInterface $state State to add for this Service

@see    CompilerPass
@throws \InvalidArgumentException when tries to add State having an existing key
357567
public function addAvailableState(StateInterface $state)
    {
        if (array_key_exists($state->getKey(), $this->availableStates)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Conflict : State key "%s" for the given State "%s" is already used in workflow "%s".',
                    $state->getKey(),
                    get_class($state),
                    $this->name
                )
            );
        }

        $state->setWorkflow($this);
        $this->availableStates[$state->getKey()] = $state;
    }
862083
public function addStates(array $states): self
    {
        $builder = clone $this;
        foreach ($states as $state) {
            $builder->states[$state->getName()] = $state;
        }
        return $builder;
    }
1178931
protected function setState($state)
    {
        if (!array_key_exists($state, $this->stateDirectives)) {
            throw new InvalidArgumentException("Invalid state {$state}");
        }
        $this->state = $state;
        return $this;
    }
852365
public function add($middleware)
        {
            if (!is_string($middleware) && !$middleware instanceof MiddlewareInterface) {
                throw new \InvalidArgumentException('Middleware must be a string or an instance of MiddlewareInterface');
            }

            $class = is_string($middleware) ? new $middleware : $middleware;
            array_push($this->middleware, $class);
        }
297846
public function addType(WidgetTypeInterface $widget)
    {
        if (!$this->hasType($widget)) {
            $this->types[$widget->getName()] = $widget;
        } else {
            throw new \InvalidArgumentException(sprintf('Widget type "%s" is already registered.', $widget->getName()));
        }
    }
649899
public function setState($state)
    {
        if (!in_array($state, $this->validStates)) {
            throw new InvalidArgumentException("Invalid editor state: $state");
        }

        $this->state = $state;

        $this->session->put($this->statePersistenceKey, $state);

        return $this;
    }
960734
public function add($method)
    {
        if (!$method instanceof MethodInterface) {
            throw new \InvalidArgumentException('This Method must be a instance of \ClassGeneration\MethodInterface');
        }
        if ($method->getName() === null) {
            $method->setName('method' . ($this->count() + 1));
        }

        parent::set($method->getName(), $method);
        return true;
    }
1084351
public function add($property)
    {
        if (!$property instanceof PropertyInterface) {
            throw new \InvalidArgumentException(
                'This Property must be a instance of \ClassGeneration\PropertyInterface'
            );
        }
        if ($property->getName() === null) {
            $property->setName('property' . ($this->count() + 1));
        }

        parent::set($property->getName(), $property);

        return true;
    }
251617
public void addState(CmsPublishItemStatus.State state) {

        switch (state) {
            case normal:
                m_normalCount += 1;
                break;
            case publish:
                m_publishCount += 1;
                break;
            case remove:
            default:
                m_removeCount += 1;
                break;
        }
    }
174156
public function track(StateInterface $state): int
    {
        $this->breadcrumbs->push($state->getName());
        $this->execution_counts[$state->getName()]++;
        return $this->execution_counts[$state->getName()];
    }
140720
public static function activate_state($state)
    {
        foreach (self::variants() as $variant => $instance) {
            if (isset($state[$variant]) && $instance->appliesToEnvironment()) {
                $instance->activateState($state[$variant]);
            }
        }
    }
1318989
public function register(ContainerInterface $container, Configurable $config)
    {
        if (! $config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }

        $logger = new Logger($config->name, $config->handlers);

        $container->add($config->getServiceName(), $logger);
    }
1239772
public function createEvent(StateInterface $sourceState, $eventName)
    {
        if ($sourceState instanceof State) {
            return $sourceState->getEvent($eventName);
        } else {
            throw new \InvalidArgumentException('Overwrite this method to implement a different type!');
        }
    }
1017017
public function register(ContainerInterface $container, Configurable $config)
    {
        if ( ! $config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }

        $requestFilter = new RequestFilter($config);

        $container->add($config->getServiceName(), $requestFilter);
    }
331209
public function setState($state)
    {
        $state &= ~248; // 0b11111000

        if (($state & ($state - 1)) !== 0) {
            throw new InvalidArgumentException("State must be a valid state value");
        }

        $this->setFlags($state);
        $this->streamCallback = null;
    }
1254865
public function storeAuthorizationState($service, $state)
    {
        $service = $this->normalizeServiceName($service);

        $states = $this->sessionScope->get(self::SESSION_STATE);
        $states[$service] = $state;
        $this->sessionScope->set(self::SESSION_STATE, $states);

        return $this;
    }
1122264
public function setState($state)
		{
		$r = array_pop($this->states);
		array_push($this->states, $state);
		$this->state = $this->states[count($this->states) - 1];
		return $r;
		}