protected final function offerProjectChoice(array $projects, $text = 'Enter a number to choose a project:')
    {
        if (!isset($this->input) || !isset($this->output) || !$this->input->isInteractive()) {
            throw new \BadMethodCallException('Not interactive: a project choice cannot be offered.');
        }

        // Build and sort a list of project options.
        $projectList = [];
        foreach ($projects as $project) {
            $projectList[$project->id] = $this->api()->getProjectLabel($project, false);
        }
        asort($projectList, SORT_NATURAL | SORT_FLAG_CASE);

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

        $id = $questionHelper->choose($projectList, $text, null, false);

        return $id;
    }
protected final function offerProjectChoice(array $projects, $text = 'Enter a number to choose a project:')
    {
        if (!isset($this->input) || !isset($this->output) || !$this->input->isInteractive()) {
            throw new \BadMethodCallException('Not interactive: a project choice cannot be offered.');
        }

        // Build and sort a list of project options.
        $projectList = [];
        foreach ($projects as $project) {
            $projectList[$project->id] = $this->api()->getProjectLabel($project, false);
        }
        asort($projectList, SORT_NATURAL | SORT_FLAG_CASE);

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

        $id = $questionHelper->choose($projectList, $text, null, false);

        return $id;
    }
protected final function offerProjectChoice ( array $ projects , $ text = 'Enter a number to choose a project:' ) { if ( ! isset ( $ this -> input ) || ! isset ( $ this -> output ) || ! $ this -> input -> isInteractive ( ) ) { throw new \ BadMethodCallException ( 'Not interactive: a project choice cannot be offered.' ) ; } // Build and sort a list of project options. $ projectList = [ ] ; foreach ( $ projects as $ project ) { $ projectList [ $ project -> id ] = $ this -> api ( ) -> getProjectLabel ( $ project , false ) ; } asort ( $ projectList , SORT_NATURAL | SORT_FLAG_CASE ) ; /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */ $ questionHelper = $ this -> getService ( 'question_helper' ) ; $ id = $ questionHelper -> choose ( $ projectList , $ text , null , false ) ; return $ id ; }
Offer the user an interactive choice of projects.

@param Project[] $projects
@param string    $text

@return string
The chosen project ID.
Offer the user an interactive choice of projects .