{@inheritdoc}

@throws \InvalidArgumentException
966847
public function setType(?string $type): void
    {
        if (!in_array($type, static::getTypes(), true)) {
            throw new \InvalidArgumentException('Wrong zone type supplied.');
        }

        $this->type = $type;
    }
916504
public function check(...$args)
    {
        if (count($args) !== count($this->constraints)) {
            throw new InvalidArgumentException(
                'Argument number mismatch.'
            );
        }

        foreach ($args as $key => $arg) {
            if (!$this->constraints[$key]->check($arg, $args)) {
                throw new InvalidArgumentException(vsprintf(
                    'Argument %s does not meet its constraints.'
                    . "\nFailed constraint: %s\nValue provided:%s",
                    [
                        $key,
                        $this->constraints[$key]->toString(),
                        print_r($arg, true)
                    ]
                ));
            }
        }
    }
960682
public function execute($options = [])
    {
        if (! is_array($options) && ! $options instanceof Option) throw new \InvalidArgumentException('invalid option');
        if (! $this->do) throw new \Samurai\Samurai\Exception\LogicException('preset task something do.');

        $option = $this->getOption($this->do);
        if (is_array($options)) {
            $option->importFromArray($options);
        } else {
            $option->import($options);
        }
        $option->validate();
        $this->{$this->do . 'Task'}($option);
    }
1244463
public function offsetGet($offset)
    {
        if (isset($this->storage[$offset])) {
            return $this->storage[$offset];
        }
        if (!isset($this->storageDefs[$offset])) {
            if (empty($this->allowsUndefinedKey)) {
                throw new InvalidArgumentException(
                    sprintf("Key '%s' does not exists", $offset)
                );
            }
            return;
        }
        if (is_array($def = $this->storageDefs[$offset])) {
            if (isset($def['getter'])) {
                return $this->{$def['getter']}();
            }
            if (isset($def['default'])) {
                if (   is_int($def['default'])
                    && isset($def['enum'][$def['default']])
                ) {
                    return $this->storage[$offset] = $def['enum'][$def['default']];
                }
                return $this->storage[$offset] = $def['default'];
            }
        }
    }
127124
public function set($key, $value)
    {
        if (!is_string($key)) {
            throw new \InvalidArgumentException('$key must be string');
        }

        if (!is_string($value) && !is_numeric($value) && !is_bool($value)) {
            throw new \InvalidArgumentException('$value must be string, int or bool');
        }

        $this->annotations[] = [
            'key' => $key,
            'value' => (string) $value
        ];
    }
536131
public function offsetSet($offset, $value): void
    {
        if ($this->isValidEntity($value)) {
            if (is_null($offset) || mb_strlen($offset) == 0) {
                $this->list[] = $value;
            } else {
                $this->list[$offset] = $value;
            }
        } else {
            throw new \InvalidArgumentException(sprintf('This collection does\'t accept this entity "%s"', gettype($value)));
        }
    }
904386
public function set($key, $value)
    {
        if (!is_string($key)) {
            throw new \InvalidArgumentException('Expected string as key');
        }

        if (!is_string($value)) {
            throw new \InvalidArgumentException('Expected string as value');
        }

        $queryString = 'REPLACE INTO ' . $this->name . ' VALUES (:key, :value);';
        $stmt = $this->db->prepare($queryString);
        $stmt->bindParam(':key', $key, \PDO::PARAM_STR);
        $stmt->bindParam(':value', $value, \PDO::PARAM_STR);
        $stmt->execute();
        $this->data[(string)$key] = $value;

        return $this->data[$key];
    }
464775
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $availableTypes = ['uniq', 'fk', 'idx'];
        $type = strtolower($input->getOption('type'));
        if (!\in_array($type, $availableTypes, true)) {
            throw new \InvalidArgumentException(
                sprintf('Unknown type "%s", available types are "%s".', $type, implode('","', $availableTypes))
            );
        }
        $tableName = $input->getOption('table');
        $columns = explode(',', $input->getOption('columns'));
        $output->writeln(sprintf(
            'Index name: %s',
            $this->generateIdentifierName(array_merge([$tableName], $columns), $type)
        ));
        return 0;
    }
422917
public function add($value)
    {
        if ( ! is_scalar($value)) {
            throw new InvalidArgumentException(sprintf(
                'Argument 1 passed to %s must be a scalar value, %s given',
                __METHOD__,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        parent::offsetSet(null, $value);
    }
64039
public function setData($data)
    {
        if ($data instanceof Collection || $data instanceof Model) {
            $this->data = $data->toArray();
        } elseif (is_array($data) || $data instanceof Repository) {
            $this->data = $data;
        } else {
            throw new \InvalidArgumentException('Data must be an array, a Collection, a Model or a Repository');
        }
    }
962314
public function relationshipValue($key)
    {
        if (!isset($this->keyToIndexMap[$key]) || !$this->values[$this->keyToIndexMap[$key]] instanceof Relationship) {
            throw new \InvalidArgumentException(sprintf('value for %s is not of type %s', $key, 'RELATIONSHIP'));
        }

        return $this->value($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');
        }
    }
1117665
public function configure(Configuration $configuration)
    {
        foreach ($this->nsMap as $type => $map) {
            if (!count($map)) {
                continue;
            }
            $method = 'get' . ucfirst($type) . 'NamespacesMap';
            if (!method_exists($configuration, $method)) {
                throw new InvalidArgumentException('Invalid type of structure namespaces map: ' . $type);
            }
            /** @var $nsMap Configuration\NamespacesMap */
            $nsMap = $configuration->$method();
            $nsMap->add($map);
        }
    }
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;
    }
944207
public function setData($data)
    {
        if(!$this->getIsValidData($data))
        {
            throw new InvalidDataException();
        }

        if(!$this->getIsAllKeysValid($data))
        {
            throw new InvalidKeyException();
        }

        if(!$this->getIsAllValuesValid($data))
        {
            throw new InvalidValueException();
        }

        $this->__data = $data;
        $this->invalidateKeycache();
    }
440456
protected function setFields($fields)
    {
        if(is_array($fields)) {
            foreach ( $fields as $field ) {
                if ( !in_array($field, $this->fieldsWhitelist) ) {
                    throw new \InvalidArgumentException(sprintf('The field `%s` was not recognized.', $field));
                }
            }
        } elseif($fields === true) {
            $fields = $this->fieldsWhitelist;
        } else {
            throw new \InvalidArgumentException("The argument passed to setFields was invalid");
        }

        $this->setQueryParam('fields', $fields);
    }
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;
        }
    }