protected final function offerEnvironmentChoice(array $environments)
    {
        if (!isset($this->input) || !isset($this->output) || !$this->input->isInteractive()) {
            throw new \BadMethodCallException('Not interactive: an environment choice cannot be offered.');
        }

        /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */
        $questionHelper = $this->getService('question_helper');
        $default = $this->api()->getDefaultEnvironmentId($environments);

        // Build and sort a list of options (environment IDs).
        $ids = array_keys($environments);
        sort($ids, SORT_NATURAL | SORT_FLAG_CASE);

        $id = $questionHelper->askInput('Environment ID', $default, array_keys($environments), function ($value) use ($environments) {
            if (!isset($environments[$value])) {
                throw new \RuntimeException('Environment not found: ' . $value);
            }

            return $value;
        });

        $this->stdErr->writeln('');

        return $environments[$id];
    }
protected final function offerEnvironmentChoice(array $environments)
    {
        if (!isset($this->input) || !isset($this->output) || !$this->input->isInteractive()) {
            throw new \BadMethodCallException('Not interactive: an environment choice cannot be offered.');
        }

        /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */
        $questionHelper = $this->getService('question_helper');
        $default = $this->api()->getDefaultEnvironmentId($environments);

        // Build and sort a list of options (environment IDs).
        $ids = array_keys($environments);
        sort($ids, SORT_NATURAL | SORT_FLAG_CASE);

        $id = $questionHelper->askInput('Environment ID', $default, array_keys($environments), function ($value) use ($environments) {
            if (!isset($environments[$value])) {
                throw new \RuntimeException('Environment not found: ' . $value);
            }

            return $value;
        });

        $this->stdErr->writeln('');

        return $environments[$id];
    }
protected final function offerEnvironmentChoice ( array $ environments ) { if ( ! isset ( $ this -> input ) || ! isset ( $ this -> output ) || ! $ this -> input -> isInteractive ( ) ) { throw new \ BadMethodCallException ( 'Not interactive: an environment choice cannot be offered.' ) ; } /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */ $ questionHelper = $ this -> getService ( 'question_helper' ) ; $ default = $ this -> api ( ) -> getDefaultEnvironmentId ( $ environments ) ; // Build and sort a list of options (environment IDs). $ ids = array_keys ( $ environments ) ; sort ( $ ids , SORT_NATURAL | SORT_FLAG_CASE ) ; $ id = $ questionHelper -> askInput ( 'Environment ID' , $ default , array_keys ( $ environments ) , function ( $ value ) use ( $ environments ) { if ( ! isset ( $ environments [ $ value ] ) ) { throw new \ RuntimeException ( 'Environment not found: ' . $ value ) ; } return $ value ; } ) ; $ this -> stdErr -> writeln ( '' ) ; return $ environments [ $ id ] ; }
Offers a choice of environments.

@param Environment[] $environments

@return Environment
Offers a choice of environments .