HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: /virtual/nagasaki/public_html/ec/tests/Eccube/Tests/Command/QuestionHelperMock.php
<?php

namespace Eccube\Tests\Command;

use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

class QuestionHelperMock extends QuestionHelper
{

    /**
     * @var callable
     */
    private $mockHandler;

    /**
     * @param callable
     */
    public function setMockHandler($mockHandler)
    {
        $this->mockHandler = $mockHandler;
    }

    /**
     * @param OutputInterface
     * @param Question
     */
    public function doAsk(OutputInterface $output, Question $question)
    {
        $this->writePrompt($output, $question);
        $output->write(' => ');

        $response = call_user_func($this->mockHandler, $question->getQuestion(), $question);

        if (strlen($response) <= 0) {
            $response = $question->getDefault();
        }

        if ($normalizer = $question->getNormalizer()) {
            $response = $normalizer($response);
        }

        $output->writeln(print_r($response, true));
        return $response;
    }
}