Get the given handler segment for the given command.

@param  mixed  $command
@param  int  $segment
@return string
350408
protected function inflectValidatorSegment($command, $segment)
	{
		$className = get_class($command);

		if (isset($this->validatorMappings[$className]))
		{
			return $this->getValidatorMappingSegment($className, $segment);
		}
		elseif ($this->validatorMapper)
		{
			return $this->getValidatorMapperSegment($command, $segment);
		}

		return false;
	}
321267
public function get($command)
    {
        $className = ucfirst($command);
        $className = "PortaText\\Command\\Api\\$className";
        if (!class_exists($className)) {
            throw new \InvalidArgumentException(
                "Command $command does not exist"
            );
        }
        return new $className();
    }
651131
public function resolveHandler($command)
    {
        if ($command instanceof SelfHandling) {
            return $command;
        }

        return $this->container->make($this->getHandlerClass($command));
    }
575247
public function getCommandHandler($command)
    {
        if ($this->hasCommandHandler($command)) {
            return $this->container->make($this->handlers[get_class($command)]);
        }

        return false;
    }
862620
public function resolveCommand($command)
    {
        if ($fullPaths = $this->findWhere($command)) {
            $fullPaths = preg_split('/[\r\n]/', trim($fullPaths));
            $command = end($fullPaths);
        }

        return $command;
    }
901522
public function get_segment($segment, $default = null)
	{
		if (isset($this->segments[$segment - 1]))
		{
			return $this->segments[$segment - 1];
		}

		return \Fuel::value($default);
	}
1232318
private function apiCall($command, $data=array()) {
			if (!isset($this->rest_commands[$command])) {
				return false;
			}

			$cmd = $this->rest_commands[$command];

			$url = $cmd['url'];
			$url = str_replace(array('{k}', '{s}') ,array($this->nx_key, $this->nx_secret), $url);

			$parsed_data = array();
			foreach ($data as $k => $v) $parsed_data['{'.$k.'}'] = $v;
			$url = str_replace(array_keys($parsed_data) ,array_values($parsed_data), $url);

			$url = trim($this->rest_base_url, '/') . $url;
			$post_data = '';

			// If available, use CURL
			if (function_exists('curl_version')) {

				$to_nexmo = curl_init( $url );
				curl_setopt( $to_nexmo, CURLOPT_RETURNTRANSFER, true );
				curl_setopt( $to_nexmo, CURLOPT_SSL_VERIFYPEER, false);
				curl_setopt($to_nexmo, CURLOPT_HTTPHEADER, array('Accept: application/json'));

				if ($cmd['method'] == 'POST') {
					curl_setopt( $to_nexmo, CURLOPT_POST, true );
					curl_setopt( $to_nexmo, CURLOPT_POSTFIELDS, $post_data );
				}

				$from_nexmo = curl_exec( $to_nexmo );
				$curl_info = curl_getinfo($to_nexmo);
				$http_response_code = $curl_info['http_code'];
				curl_close ( $to_nexmo );

			} elseif (ini_get('allow_url_fopen')) {
				// No CURL available so try the awesome file_get_contents

				$opts = array('http' =>
					array(
						'method'  => 'GET',
						'header'  => 'Accept: application/json'
					)
				);

				if ($cmd['method'] == 'POST') {
					$opts['http']['method'] = 'POST';
					$opts['http']['header'] .= "\r\nContent-type: application/x-www-form-urlencoded";
					$opts['http']['content'] = $post_data;
				}

				$context = stream_context_create($opts);
				$from_nexmo = file_get_contents($url, false, $context);

				// et the response code
				preg_match('/HTTP\/[^ ]+ ([0-9]+)/i', $http_response_header[0], $m);
				$http_response_code = $m[1];

			} else {
				// No way of sending a HTTP post :(
				return false;
			}

			$data = json_decode($from_nexmo, true);
			return array(
				'data' => $data,
				'http_code' => (int)$http_response_code
			);

		}
595381
public function segment($segment)
    {
        $segments = $this->segments;

        return isset($segments[$segment - 1]) ? $segments[$segment - 1] : false;
    }
684671
public function processCommand($command)
    {
        // Add environment flag to commands
        $stage = $this->connections->getCurrentConnectionKey()->stage;
        if (Str::contains($command, 'artisan') && $stage) {
            $command .= ' --env="'.$stage.'"';
        }

        return $command;
    }
1017823
public function getProcessByCommand(string $command) : Process {
        if( ! array_key_exists($command, $this->processes) ) {
            $this->watch($command);
        }

        foreach($this->getWatchedProcesses() as $process) {
            if($process->getCommand() === $command) {
                return $process;
            }
        }
    }
570915
public function handle($command)
    {
        $comment = $this->writeComment->by($command->userId)->withText($command->body)->about($command->ticketId)->get();
        $this->commentRepository->save($comment);

        $this->dispatchEventsFor($this->writeComment);

        return $comment;
    }
1238818
public function getCommand($command): Command
    {
        if (isset($this->aliases[$command])) {
            return $this->aliases[$command];
        }

        if (isset($this->commands[$command])) {
            return $this->commands[$command];
        }

        throw new CommandNotFoundException($this, $command);
    }
1058565
public function findCommandHandlerFor(Command $command)
    {
        if (!isset($this->subscriptions[$command->commandName()])) {
            throw new CommandHandlerNotFoundException(sprintf('No handler was found for command %s', $command->commandName()));
        }

        return $this->subscriptions[$command->commandName()];
    }
1075591
public function execute(Command $command)
    {
        $handler = $this->resolver->resolve($command);

        return $handler->handle($command);
    }
620945
public function getCallbacks($command)
    {
        $result = array();
        $command = strtolower($command);

        if (isset($this->_callbacks[$command])) {
            $result = $this->_callbacks[$command];
        }

        return $result;
    }
876281
protected function getKeyFromBlockingListCommands(string $command, array $arguments)
    {
        if ($this->checkSameSlotForKeys(\array_slice($arguments, 0, \count($arguments) - 1))) {
            return $arguments[0];
        }

        return null;
    }
1300392
public function getHandlerForCommand($commandName)
    {
        if (!isset($this->handlers[$commandName])) {
            throw MissingHandlerException::forCommand($commandName);
        }

        return $this->handlers[$commandName];
    }