Extract format

@param InputInterface $input

@return null|string
352854
protected function extractFormat(InputInterface $input)
    {
        if (null === $format = $input->getOption('format')) {
            if (null !== $file = $input->getArgument('file')) {
                $ext = mb_strtolower(pathinfo($file, PATHINFO_EXTENSION));
                if ('txt' === $ext) {
                    $format = PlantUML::FORMAT_TXT;
                } elseif ('uml' === $ext) {
                    $format = PlantUML::FORMAT_UML;
                } elseif ('png' === $ext) {
                    $format = PlantUML::FORMAT_PNG;
                } elseif ('svg' === $ext) {
                    $format = PlantUML::FORMAT_SVG;
                } elseif ('atxt' === $ext) {
                    $format = PlantUML::FORMAT_ATXT;
                } elseif ('utxt' === $ext) {
                    $format = PlantUML::FORMAT_UTXT;
                }
            }
        }

        return $format;
    }
337578
private function analyzeSection( $input ) {
		//Remove trailing sharp, if any
		$input = preg_replace( '/#\s*$/', '', $input );

		//Old preg_split regex: "/(^|\n)\s*\#[^\#\:\*]/"
		$parsed = preg_split( "/(^|\n)\#/", $input );
		//Shift off first empty element:
		array_shift( $parsed );

		foreach( $parsed as &$parsee ){ //Foreach line
			//If the line is empty for some reason, ignore
			$parsee = trim( $parsee );
			if( empty( $parsee ) ) continue;

			//If the line has been indented (disabled), or is a comment, ignore
			if( ( $parsee[0] == ':' ) || ( $parsee[0] == '*' ) || ( $parsee[0] == '#' ) ) {
				$parsee = '///###///';
				continue;
			}; //struck-out vote or comment

			$parsedsig = $this->findSigInLine( $parsee, $iffy ); //Find signature
			$orgsig = $parsee;
			$parsee = array();
			$parsee['context'] = $orgsig;
			if( $parsedsig === false ) {
				$parsee['error'] = 'Signature not found';
			} else {
				$parsee['name'] = $parsedsig;
			}
			if( @$iffy == 1 ) {
				$parsee['iffy'] = '1';
			}
		} //Foreach line

		if( ( count( $parsed ) == 1 ) && ( @trim( $parsed[0]['name'] ) == '' ) ) { //filters out placeholder sharp sign used in empty sections
			$parsed = array();
		}

		//Delete struck-out keys "continued" in foreach
		foreach( $parsed as $key => $value ){
			if( $value == '///###///' ) {
				unset( $parsed[$key] );
			}
		}

		return $parsed;
	}
1232562
public function getFormattedInput($operator, $input)
    {
        // if we use custom formatter
        if (is_callable($this->inputFormatter)) {
            $function = $this->inputFormatter;

            return $function($this, $operator, $input);
        } // else, use standard input converter

            switch ($this->getDataFormat()) {
                // date/time format dd/mm/YYYY HH:ii:ss
                case self::FORMAT_DATE:
                    $params = explode('/', str_replace(array('-', ' ',':'), '/', $input));
                    // only year ?
                    if (count($params) == 1) {
                        $fInput = $params[0];
                    } // month/year ?
                    elseif (count($params) == 2) {
                        $fInput = sprintf('%04d-%02d', $params[1], $params[0]);
                    } // day/month/year ?
                    elseif (count($params) == 3) {
                        $fInput = sprintf('%04d-%02d-%02d', $params[2], $params[1], $params[0]);
                    } // day/month/year hour ?
                    elseif (count($params) == 4) {
                        $fInput = sprintf('%04d-%02d-%02d %02d', $params[2], $params[1], $params[0], $params[3]);
                    } // day/month/year hour:minute ?
                    elseif (count($params) == 5) {
                        $fInput = sprintf(
                            '%04d-%02d-%02d %02d:%02d',
                            $params[2],
                            $params[1],
                            $params[0],
                            $params[3],
                            $params[4]
                        );
                    } // day/month/year hour:minute:second ?
                    elseif (count($params) == 6) {
                        $fInput = sprintf(
                            '%04d-%02d-%02d %02d:%02d:%02d',
                            $params[2],
                            $params[1],
                            $params[0],
                            $params[3],
                            $params[4],
                            $params[5]
                        );
                    } // default, same has raw value
                    else {
                        $fInput = $input;
                    }
                    break;
                case self::FORMAT_INTEGER:
                    $fInput = (int) $input;
                    switch ($operator) {
                        case self::TYPE_NOT_LIKE:
                            $operator = self::TYPE_NOT_EQUAL;
                            break;
                        case self::TYPE_LIKE:
                        case self::TYPE_LIKE_WORDS_AND:
                        case self::TYPE_LIKE_WORDS_OR:
                        case self::TYPE_AUTO:
                            $operator = self::TYPE_EQUAL_STRICT;
                            break;
                    }
                    break;
                case self::FORMAT_TEXT:
                default:
                    $fInput = $input;
                    break;
            }

        return array($operator, $fInput);
    }
793319
protected function filter($input): string
    {
        $input = parent::filter((string)$input);
        return preg_replace('/\s/', '', $input);
    }
9947
protected function cleanString($input)
	{
		return htmlentities(
			$input,
			$this->parent->getConfig('htmlentities_flags', ENT_QUOTES),
			$this->parent->getConfig('htmlentities_encoding', 'UTF-8'),
			$this->parent->getConfig('htmlentities_double_encode', false)
		);
	}
1332027
public function formatString($input)
    {
        if (is_array($input)) {
            $input = join(', ', $input);
        }
        $output = strip_tags($input);
        $output = str_replace(array("\r", "\n"), array(' ', ' '), $output);
        
        $output = $this->filterCsvInjection($output);
        
        return $output;
    }
790498
protected function tempScripts($input)
    {
        // Dindent does not indent <script> body. Instead, it temporary removes it from the code,
        // indents the input, and restores the script body.
        if (preg_match_all('/<script\b[^>]*>([\s\S]*?)<\/script>/mi', $input, $matches)) {
            $this->temporaryReplacementsScript = $matches[0];

            foreach ($matches[0] as $i => $match) {
                $input = str_replace($match, '<script>' . ($i + 1) . '</script>', $input);
            }
        }

        return $input;
    }
112838
public function formatString($input)
    {
        if (is_array($input)) {
            $input = join(', ', $input);
        }
        $output = strip_tags($input);
        $output = str_replace(array("'", "\r", "\n"), array("''", ' ', ' '), $output);
        //$output = "'" . $output . "'";
        return $output;
    }
1059624
private function fromCamelCase($input) {
	       
	        $a = preg_split(
		        '/(^[^A-Z]+|[A-Z][^A-Z]+)/',
		        $input,
		        -1, /* no limit for replacement count */
		        PREG_SPLIT_NO_EMPTY /*don't return empty elements*/
		            | PREG_SPLIT_DELIM_CAPTURE /*don't strip anything from output array*/
		    );
	        return strtolower(join($a, "-"));
	}
741836
private function withParam( string$input )
	{
		return str_replace('$_FLAG_$',"__HTSL_CTRL_FLAG_{$this->id}__",preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/',function( array$matches ){
			$param= $this->param;

			if( isset($matches[1]) ){
				array_map(...[
					function($replacer)use(&$param){
						list($pattern,$replacement,)= preg_split('/(?<!\\\\)\\//',$replacer);
						$param= preg_replace(...[
							"/$pattern/",
							preg_replace('/^\\\\_$/','',$replacement),
							$param,
						]);
					},
					preg_split(
						'/(?<!\\\\)\\/\\//'
						,
						trim($matches[1],'/')
					),
				]);
			}
			return $param;
		},$input));
	}
1260342
protected function parseHeaders($input)
    {
        if ($input !== '') {
            // Unfold the input
            $input   = preg_replace('/' . $this->params['crlf'] . "(\t| )/", ' ', $input);
            $headers = explode($this->params['crlf'], trim($input));

            foreach ($headers as $value) {
                $hdr_name  = substr($value, 0, $pos = strpos($value, ':'));
                $hdr_value = substr($value, $pos+1);

                if ($hdr_value[0] == ' ') {
                    $hdr_value = substr($hdr_value, 1);
                }

                $return[] = array(
                    'name'  => $hdr_name,
                    'value' => $this->params['decode_headers'] ? $this->decodeHeader($hdr_value) : $hdr_value,
                );
            }
        }
        else {
            $return = array();
        }

        return $return;
    }
745580
public static function escapeInput(string $input): string
    {
        $escaped_input = htmlspecialchars(stripslashes(trim($input)));
        return $escaped_input;
    }
1235278
public function getType($input)
    {
        // Make an array to loop through
        $inputs = explode('|', $input);

        foreach ($inputs as $index => $input) {
            $list = (bool) preg_match('/\[\]$/', $input);
            if ($list === true) {
                $input = substr($input, 0, -2);
            }

            // make the type case insensitive
            $type = strtolower(trim($input));

            // Check if we can convert the type to a known type
            if (array_key_exists($type, $this->phpTypeMapping) === true) {
                $type = $this->phpTypeMapping[$type];
            }

            // Check if it is a predefined type
            if (in_array($type, $this->phpTypes) === true) {
                $inputs[$index] = $type . ($list ? '[]' : '');
                continue;
            }

            // Reset the type. Maybe it is a class definition
            $type = $input;

            if (
                $this->isClassDefined($type) === true ||
                $this->isInterfaceDefined($type) === true ||
                $this->isTraitDefined($type) === true
            ) {
                $inputs[$index] = $type . ($list ? '[]' : '');
                continue;
            }

            throw Exception\Type::isNotDefined($type);
        }

        return implode('|', $inputs);
    }
1243508
private function validateInput(InputInterface $input)
    {
        if (!$input->getOption('grep')) {
            foreach (['invert', 'insensitive'] as $option) {
                if ($input->getOption($option)) {
                    throw new RuntimeException('--' . $option . ' does not make sense without --grep');
                }
            }
        }
    }
696907
public static function handleInput(InputInterface $input)
    {
        $configOption = $input->getOption('configuration');
        $configFile = ConfigLocator::locate($configOption);
        $configuration = ConfigLoader::loadConfig($configFile);

        $phpunit = $configuration->getPHPUnitConfiguration();
        if (null !== $input->getOption('bootstrap')) {
            $phpunit['bootstrap'] = $input->getOption('bootstrap');
        }

        if (isset($phpunit['bootstrap'])) {
            FileLoader::loadFile($phpunit['bootstrap']);
        }

        return $configuration;
    }
100292
protected function parse($input): string
    {
        if (!is_array($input)) {
            return json_encode($input);
        }

        $parsed = "";
        foreach ($input as $key => $value) {
            $key = (!is_numeric($key) ? ($key . ": " ) : '');
            if (!is_array($value)) {
                $parsed .= $key . $this->parse($value) . ', ';
            } elseif (is_null(key($value)) || is_numeric(key($value))) {
                $parsed .= $key . "[" . $this->parse($value) . "], ";
            } else {
                $parsed .= $key . "{" . $this->parse($value) . "}, ";
            }
        }

        return rtrim($parsed, ', ');
    }
1160274
protected function getTemplate(InputInterface $input)
    {
        $template = $this->getTemplateFactory()->get('twig');
        $template->setName($input->getOption('template'));

        return $template;
    }