@param       string      $helperType     helper type eg. tag, option, field, choise
@return      bool

@throws InvalidArgumentException
504150
public function hasName($helperType)
    {
        if ($this->isValidKey($helperType)) {
            if ($this->getHelperMap()->hasKey($helperType)) {
                return true;
            }
        } else {
            throw new InvalidArgumentException('Invalid form helper type given');
        }
        return false;
    }
5615
private function checkFieldsMapType($fieldsMap)
    {
        if (!is_array($fieldsMap) && !$fieldsMap instanceof \ArrayAccess) {
            throw new \InvalidArgumentException(sprintf(
                'Parameter fieldsMap passed to %s should be an array or \ArrayAccess.'
                .' Given: %s',
                __CLASS__,
                is_object($fieldsMap) ? get_class($fieldsMap) : gettype($fieldsMap)
            ));
        }
    }
141237
public function getFieldType($type)
    {
        $types = array_keys(static::$availableFieldTypes);

        if (!$type || trim($type) == '') {
            throw new \InvalidArgumentException('Field type must be provided.');
        }

        if (array_key_exists($type, $this->customTypes)) {
            return $this->customTypes[$type];
        }

        if (!in_array($type, $types)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Unsupported field type [%s]. Available types are: %s',
                    $type,
                    join(', ', array_merge($types, array_keys($this->customTypes)))
                )
            );
        }

        $namespace = __NAMESPACE__.'\\Fields\\';

        return $namespace . static::$availableFieldTypes[$type];
    }
777725
private function setupTemplateEngine()
    {
        if (!isset($this->options[self::OPTION_TYPE])) {
            throw new InvalidArgumentException(
                'Cannot setup template engine. Option "' . self::OPTION_TYPE . '" is required.'
            );
        }

        $this->templateEngine = $this->createTemplateEngine($this->options[self::OPTION_TYPE], $this->options);
        $this->setupExtensionAdapter();
    }
676803
public function setRegexp($regexp)
    {
        if (is_string($regexp)) {
            $this->regexp = $regexp;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($regexp) . "' for argument 'regexp' given. String expected."
            );
        }
    }
566309
private function executeChoice(SymfonyStyle $helper, $choice)
    {
        if (self::ACTION_DATABASE_IMPORT === $choice) {
            return $this->actionDatabaseImport($helper);
        }

        throw new \RuntimeException(sprintf('Unknown choice %s', $choice));
    }
897908
protected function addHelpValue($key, $value)
    {
        if (is_object($value)) {
            throw new \InvalidArgumentException(sprintf('The HelpValue with ID "%s" you are trying to add is an object. Use $this->addHelpMock() instead.', $key));
        }

        if (isset($this->helpValues[$key])) {
            throw new \LogicException('The HelpValue you are trying to add is already set. Set the fourth parameter to "true" to overwrite it.');
        }

        $this->helpValues[$key] = $value;

        return $this;
    }
148328
public function of($name, $callback = null)
    {

        $type = $this->definition['name'];

        if (is_null($type) || !property_exists($this, $type)) {
            throw new RuntimeException('Not supported.');
        } elseif (!isset($this->keyMap[$name])) {
            throw new InvalidArgumentException("Name [{$name}] is not available.");
        }

        $id = $this->keyMap[$name];

        if (is_callable($callback)) {
            call_user_func($callback, $this->{$type}[$id]);
        }


        return $this->{$type}[$id];
    }
400855
public function create($formClass, array $options = [], array $data = [])
    {
        $class = $this->getNamespaceFromConfig() . $formClass;

        if (!class_exists($class)) {
            throw new \InvalidArgumentException(
                'Form class with name ' . $class . ' does not exist.'
            );
        }

        $form = $this->setDependenciesAndOptions($this->container->make($class), $options, $data);

        $form->buildForm();

        $this->eventDispatcher->dispatch(new AfterFormCreation($form));

        $form->filterFields();

        return $form;
    }
788820
public function getHelperCount($helperType)
    {
        if ($this->isValidKey($helperType)) {
            if (!is_null($formHelperMap = $this->getHelperMap()->get($helperType))) {
                return count($formHelperMap);
            }
            return 0;
        } else {
            throw new InvalidArgumentException('Invalid form helper type given');
        }
    }
569735
public function formElement(IElement $element)
    {
        if ($element instanceof Textarea) {
            return $this->formTextarea($element);
        } elseif ($element instanceof Select) {
            return $this->formSelect($element);
        } elseif ($element instanceof Submit) {
            return $this->formInput($element);
        } elseif ($element instanceof Button) {
            // todo: is it right?
            throw new InvalidArgumentException("Button element should be rendered without Helper.");
        } else {
            return $this->formInput($element);
        }
    }
998704
public function parse($inputArgs = null) {
        $args = $this->getCommandLineArgs($inputArgs);
        if (count($args)) {
            $this->scriptName = array_shift($args);
        }

        // build help option
        $helpOpt = false;
        if ($this->helpLong) {
            $helpOpt = new Option();
            $helpOpt->long($this->helpLong);
        }
        if ($this->helpShort) {
            if (!$helpOpt) {
                $helpOpt = new Option();
            }
            $helpOpt->short($this->helpShort);
        }
        if ($helpOpt) {
            $this->configOpts[Parser::HELP_OPTION_NAME] = $helpOpt;
        }

        try {
            $parser = new Parser($this->configOpts, $this->configArgs);
            $parser->parse($args);
        }
        catch (UsageException $e) {
            if ($this->errorHandling) {
                $this->handleUsageError($e);
            }
            else {
                // re-throw exception
                throw $e;
            }
        }
        catch (ShowHelpException $e) {
            $this->showHelp();
        }

        $this->result = $parser->getResult();
    }
1099967
protected function checkModuleArgument($paramValue)
    {
        if (!preg_match('#^([a-z0-9]+):([\+-]?[0-9]+|up|down)$#i', $paramValue, $matches)) {
            throw new \InvalidArgumentException(
                'Arguments must be in format moduleName:[+|-]position where position is an integer or up or down.'
            );
        }

        $this->moduleQuery->clear();
        $module = $this->moduleQuery->findOneByCode($matches[1]);
        if ($module === null) {
            throw new \RuntimeException(sprintf('%s module does not exists. Try to refresh first.', $matches[1]));
        }

        $this->modulesList[] = $matches[1];
        $this->positionsList[] = $matches[2];
    }
983742
public function add($name, $type = 'text', array $options = [], $modify = false)
    {
        if (!$name || trim($name) == '') {
            throw new \InvalidArgumentException(
                'Please provide valid field name for class ['. get_class($this) .']'
            );
        }

        if ($this->rebuilding && !$this->has($name)) {
            return $this;
        }

        $this->addField($this->makeField($name, $type, $options), $modify);

        return $this;
    }
1124853
private function executeChoice(SymfonyStyle $helper, $choice)
    {
        if (self::ACTION_CACHE_CLEAR === $choice) {
            return $this->actionCacheClear($helper);
        }

        if (self::ACTION_TESTING_CLEAR === $choice) {
            $helper->note('Removes all temporary files generated to save testing output.');

            return $this->actionTestingClear($helper);
        }

        throw new \RuntimeException(sprintf('Unknown choice %s', $choice));
    }
18677
protected function validateOptions(array $options)
    {
        foreach ($options as $option => $value) {
            if (!array_key_exists($option, $this->defaultOptions)) {
                throw new \InvalidArgumentException(sprintf('Unrecognized option "%s".', $option));
            }
        }
        if (isset($options['html']) && !is_bool($options['html'])) {
            throw new \InvalidArgumentException('The option "html" must be a boolean.');
        }
        if (isset($options['html_attributes']) && !is_array($options['html_attributes'])) {
            throw new \InvalidArgumentException('The option "html_attributes" must be an array.');
        }
    }
659566
public function isValidRegex()
    {
        set_error_handler(function ($errno, $errstr) {
            throw new InvalidArgumentException($errstr, $errno);
        }, E_WARNING);

        $valid = true;

        try {
            preg_match($this->string, 'tester');
        } catch (InvalidArgumentException $e) {
            $valid = false;
        }

        restore_error_handler();

        return $valid;
    }