<?php

namespace Aedart\Scaffold\Console\Style;

use Aedart\Scaffold\Contracts\Console\Style\Factory;
use Aedart\Scaffold\Testing\Console\Style\ExtendedStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class ExtendedStyleFactory implements Factory
{
    /**
     * Input values
     *
     * @var resource
     */
    protected $inputValues;

    /**
     * ExtendedStyleFactory constructor.
     *
     * @param resource $inputValues
     */
    public function __construct($inputValues)
    {
        $this->inputValues = $inputValues;
    }

    /**
     * Make a new Symfony Style instance
     *
     * @param InputInterface $input
     * @param OutputInterface $output
     *
     * @return SymfonyStyle
     */
    public function make(InputInterface $input, OutputInterface $output)
    {
        $style = new ExtendedStyle($input, $output);

        $style->getQuestionHelper()->setInputStream(
            $this->inputValues
        );

        return $style;
    }
}
<?php

namespace Aedart\Scaffold\Console\Style;

use Aedart\Scaffold\Contracts\Console\Style\Factory;
use Aedart\Scaffold\Testing\Console\Style\ExtendedStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Extended Style Output Factory
 *
 * <br />
 *
 * Intended for testing only!
 *
 * @author Alin Eugen Deac <aedart@gmail.com>
 * @package Aedart\Scaffold\Console\Style
 */
class ExtendedStyleFactory implements Factory
{
    /**
     * Input values
     *
     * @var resource|null
     */
    protected $inputValues;

    /**
     * ExtendedStyleFactory constructor.
     *
     * @param resource|null $inputValues [optional]
     */
    public function __construct($inputValues = null)
    {
        $this->inputValues = $inputValues;
    }

    /**
     * {@inheritdoc}
     */
    public function make(InputInterface $input, OutputInterface $output)
    {
        $style = new ExtendedStyle($input, $output);

        // Set input steam (input values) if any are given
        if(isset($this->inputValues)){
            $style->getQuestionHelper()->setInputStream(
                $this->inputValues
            );
        }

        return $style;
    }
}
Change factory, set input stream only when given
Change factory, set input stream only when given
