Check whether a command is set for the current input string.

@param string $input

@return bool True if the shell has a command for the given input
341962
protected function hasCommand($input)
    {
        if (\preg_match('/([^\s]+?)(?:\s|$)/A', \ltrim($input), $match)) {
            return $this->has($match[1]);
        }

        return false;
    }
1264425
protected function verifyNetwork($input): bool
    {
        if ($this->networkRange === null) {
            return true;
        }

        if (isset($this->networkRange['mask'])) {
            return $this->belongsToSubnet($input);
        }

        $input = sprintf('%u', ip2long($input));

        $min = sprintf('%u', ip2long($this->networkRange['min']));
        $max = sprintf('%u', ip2long($this->networkRange['max']));

        return ($input >= $min) && ($input <= $max);
    }
1158627
public static function isUrl($input = false) {

        if ($input && !filter_var($input, FILTER_VALIDATE_URL) === false) {

            return true;
        }

        return false;
    }
683195
public function has($input): NodeList {
        if ($input instanceof NodeList || $input instanceof \DOMNode) {
            $inputNodes = $this->inputAsNodeList($input, false);

            $fn = function($node) use ($inputNodes) {
                $descendantNodes = $node->find('*', 'descendant::');

                // Determine if we have a descendant match.
                return $inputNodes->reduce(function($carry, $inputNode) use ($descendantNodes) {
                    // Match descendant nodes against input nodes.
                    if ($descendantNodes->exists($inputNode)) {
                        return true;
                    }

                    return $carry;
                }, false);
            };

        } elseif (is_string($input)) {
            $fn = function($node) use ($input) {
                return $node->find($input, 'descendant::')->count() != 0;
            };

        } elseif (is_callable($input)) {
            $fn = $input;

        } else {
            throw new \InvalidArgumentException('Unexpected input value of type "' . gettype($input) . '"');
        }

        return $this->getNodesMatchingInput($fn);
    }
71829
public function hasOptions($command = '') {
        if ($command) {
            $def = $this->getSchema($command);
            return $this->hasOptionsDef($def);
        } else {
            foreach ($this->commandSchemas as $pattern => $def) {
                if ($this->hasOptionsDef($def)) {
                    return true;
                }
            }
        }
        return false;
    }
600538
public function validate($input): bool
    {
        if (\is_array($this->haystack)) {
            return \in_array($input, $this->haystack, false);
        }

        if (!\is_string($this->haystack)) {
            return false;
        }

        if (empty($input)) {
            return false;
        }

        $enc = mb_detect_encoding($input);

        return mb_stripos($this->haystack, $input, 0, $enc) !== false;
    }
1222863
public static function isZip($input = false) {

        if($input) {

            if(File::isFile($input) && File::extension($input) === 'zip') {

                return true;
            }
        }

        return false;
    }
353758
protected function isUpdate($input)
    {
        return (isset($input[$this->id_field_name]) && ! empty($input[$this->id_field_name]) );
    }
600816
public function has(string $key)
    {
        if (array_key_exists($key, $this->input)) {
            return true;
        }

        try {
            $this->find($this->input, $key);
            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
528052
public function exists(string $command, array $arguments = []): bool
    {
        return $this->storage->contains(function ($value) use ($command, $arguments) {
            return $value['command'] === $command && $value['arguments'] === $arguments;
        });
    }
241251
protected function isId($input)
    {
        // Assume false result
        $result = false;

        // Make the search easier
        $input = strtolower($input);

        // We got the Id field if the first 2 or the last 2 characters are === id (e.g. IdMessages, MessageId, Id, ...)
        if (substr($input, 0, 2) === 'id' || substr($input, -2, 2) === 'id') {
            $result = true;
        }

        return $result;
    }
166261
public function validate($input): bool
    {
        if ($input instanceof DateTime) {
            return true;
        }

        if (!\is_string($input)) {
            return false;
        }

        if (null === $this->format) {
            return false !== strtotime($input);
        }

        $dateFromFormat = DateTime::createFromFormat($this->format, $input);

        return $dateFromFormat
            && $input === date($this->format, $dateFromFormat->getTimestamp());
    }
1113915
public function setInput($input)
    {
        $this->input        = $input;
        $this->currentInput = $input;
        $this->currentPos   = 0;
        $this->currentToken = null;
    }
247527
protected function isCommandDisabled($command) {
    $disabled_commands = $this->getDisabledCommands();
    if (is_array($disabled_commands) && array_key_exists($command, $disabled_commands) && $disabled_commands[$command]) {
      $this->logger->warning("The $command command is disabled.");
      return TRUE;
    }

    return FALSE;
  }
360538
private function _is_balanced($input) {
    $balance = 0;

    foreach ( str_split($input) as $char ) {
      if ( $char == '(' ) {
        $balance++;
      } else if ( $char == ')' ) {
        $balance--;
      }

      // found a close paren without a matching open paren,
      // no need to continue further
      if ( $balance < 0 ) {
        break;
      }
    }

    return $balance === 0;
  }
1271716
public function hasCommand($name = '') {
        if ($name) {
            return array_key_exists($name, $this->commandSchemas);
        } else {
            foreach ($this->commandSchemas as $pattern => $opts) {
                if (strpos($pattern, '*') === false) {
                    return true;
                }
            }
            return false;
        }
    }
14451
protected function validateInput($input)
    {
        // check
        $keys = [
            'form',
            'elements',
        ];

        switch (gettype($input)) {
            case 'array':
                foreach ($keys as $key) {
                    if (array_key_exists($key, $input) === false) {
                        throw new \Exception(
                            'Input invalid! Please make sure that input array contains keys (form, elements).'
                        );
                    }
                }
                break;
        }

        return true;
    }