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;
    }