{@inheritdoc}

@throws \InvalidArgumentException
432430
public function validate($order, Constraint $constraint): void
    {
        /** @var OrderInterface $order */
        Assert::isInstanceOf($order, OrderInterface::class);

        /** @var OrderPaymentMethodEligibility $constraint */
        Assert::isInstanceOf($constraint, OrderPaymentMethodEligibility::class);

        $payments = $order->getPayments();

        foreach ($payments as $payment) {
            if (!$payment->getMethod()->isEnabled()) {
                $this->context->addViolation(
                    $constraint->message,
                    ['%paymentMethodName%' => $payment->getMethod()->getName()]
                );
            }
        }
    }
817457
public function offsetGet($offset)
    {
        $res = null;
        if(is_array($this->obj)){
            $res = &$this->obj[$offset];
        }elseif(self::hasProperty($this->obj, $offset)){
            $res = &$this->obj->{$offset};
        }elseif(method_exists($this->obj, 'get')){
            $res = $this->obj->get($offset);
        }elseif(method_exists($this->obj, $method = 'get'.ucfirst($offset))){
            $res = $this->obj->{$method}();
        }else{
            throw new \InvalidArgumentException("offsetGet($offset) failed");
        }
        if(is_array($res) || is_object($res)){
            return new self($res);
        }
        return $res;
    }
1115720
public function execute()
    {
        $length = mb_strlen($this->getValue());

        if (filter_var($this->numberToTruncate, FILTER_VALIDATE_INT) === false) {
            throw new \InvalidArgumentException("Value to truncate by is not a number");
        } elseif (filter_var($this->numberToTruncate, FILTER_VALIDATE_INT, array(
            "options" => array(
                "min_range" => 0,
                "max_range" => $length
            )
        )) === false) {
            throw new \InvalidArgumentException("Value to truncate by is out of bounds");
        } else {
            return (new SubString($this->getValue(), 0, $length - $this->numberToTruncate))->execute();
        }
    }
584083
public function handle()
    {
        /*
         * Lookup plugin
         */
        $pluginName = $this->argument('name');
        $pluginName = PluginManager::instance()->normalizeIdentifier($pluginName);
        if (!PluginManager::instance()->exists($pluginName)) {
            throw new \InvalidArgumentException(sprintf('Plugin "%s" not found.', $pluginName));
        }

        $manager = UpdateManager::instance()->setNotesOutput($this->output);

        /*
         * Rollback plugin
         */
        $manager->rollbackPlugin($pluginName);

        /*
         * Update plugin
         */
        $this->output->writeln('<info>Reinstalling plugin...</info>');
        $manager->updatePlugin($pluginName);
    }
326481
protected function setPath($path)
    {
        if ($path !== '' && !$this->isValidPath($path)) {
            throw new \InvalidArgumentException("Invalid path '$path'");
        }
        
        $this->path = (string)$path;
    }
760144
protected function validate($object): void
    {
        $needType = $this->type();

        if (!$object instanceof $needType) {
            throw new \InvalidArgumentException("Element " . get_class($object) . " must be instance of " . $needType);
        }
    }
306872
protected function execute(InputInterface $input, OutputInterface $output)
    {
        //  validate the content types unless validation is ignored

        if ($input->getArgument('id') && !$input->getOption('ignore')) {
            $code = $this->executeValidation($input, $output);

            if ($code) {
                return $code;
            }
        }

        if ($input->getOption('delete')) {
            return $this->executeDelete($input, $output);
        }

        if (!$input->getArgument('id') && !$input->getOption('full')) {
            throw new InvalidArgumentException(
                'You need to give one or more content types or choose the --full or --delete option'
            );
        }

        return $this->executeIndex($input, $output);
    }
808195
public function call($key, $callable)
    {
        if (!is_callable($callable)) {
            throw new \InvalidArgumentException('Not a valid callable.');
        }

        if ($this->exists($key)) {
            return $this->get($key);
        }

        $args = func_get_args();
        array_shift($args);
        array_shift($args);

        $value = call_user_func_array($callable, $args);

        $this->set($key, $value);

        return $value;
    }
579052
public function get($key)
    {
        if (!array_key_exists($key, $this->getDefaults())) {
            throw new InvalidArgumentException(sprintf('Key[%s] dont exists.', $key));
        }

        if (array_key_exists($key, $this->data)) {
            return $this->data[$key];
        }

        return $this->getDefaults()[$key];
    }
843830
public function middleware(...$middlewares): void
    {
        foreach ($middlewares as $middleware) {
            if (!$middleware instanceof MiddlewareInterface && !\is_string($middleware)) {
                $type = \is_object($middleware) ? \get_class($middleware) : \gettype($middleware);
                
                throw new \InvalidArgumentException(\sprintf('Unsupported middleware type: %s', $type));
            }
            
            $this->middlewares[] = $middleware;
        }
    }
385504
public function get($key)
    {
        if ($this->has($key)) {
            return $this->params[$key];
        }

        throw new \InvalidArgumentException(sprintf("Config key %s doest not exist", $key));
    }
424073
public function &__get($key)
    {
        if (!isset($this->service[$key])) {
            throw new InvalidArgumentException(sprintf('Value "%s" is not defined.', $key));
        }

        return
            isset($this->service[$key]) &&
            is_callable($this->service[$key]) ?
                $this->service[$key]($this) :
                $this->service[$key];
    }
557728
private function initTransports()
    {
        $this->transports = array();

        foreach ($this->loadTransports() as $transport) {
            if (!$transport instanceof TransportInterface) {
                throw new \InvalidArgumentException(sprintf('Transport %s should implements TransportInterface', get_class($transport)));
            }

            $this->transports[$transport->getName()] = $transport;
        }
    }
1201922
public function setProperty($property)
    {
        if ($property === null) {
            $this->property = $property;
            return $this;
        }

        if ($property instanceof PropertyInterface) {
            if (empty($property->ident())) {
                throw new InvalidArgumentException(
                    'Property must have an identifier.'
                );
            }

            $this->property = $property;
            return $this;
        }

        if (!is_string($property)) {
            throw new InvalidArgumentException(
                'Property must be a string.'
            );
        }

        if ($property === '') {
            throw new InvalidArgumentException(
                'Property can not be empty.'
            );
        }

        $this->property = $property;
        return $this;
    }
811950
protected function getConfig($key = null)
    {
        if ($this->config === null) {
            $this->setConfig();
        }

        if (null === $key) {
            return $this->config;
        }

        if (!array_key_exists($key, $this->config)) {
            throw new InvalidArgumentException("key: '" . $key . "' is not set in configuration options.");
        }

        return $this->config[$key];
    }
135759
public function setValue($value)
    {
        if ((\is_bool($value))) {
            $this->value = (bool) $value;
        } elseif (\is_object($value) && $value instanceof self) {
            $this->value = $value->getValue();
        } else {
            throw new \InvalidArgumentException('Expected boolean');
        }
    }
97759
public function setOption($option)
    {
        if (!isset(static::$availableOptions[$option])) {
            throw new \InvalidArgumentException(sprintf(
                'Invalid option specified: "%s". Expected one of (%s)',
                $option,
                implode(', ', array_keys(static::$availableOptions))
            ));
        }
        if (!in_array(static::$availableOptions[$option], $this->options, true)) {
            $this->options[] = static::$availableOptions[$option];
        }
    }