<commit_before><?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 * @package   Zend_Console
 */

namespace Zend\Console\Prompt;

use Zend\Console\PromptInterface;
use Zend\Console\Console;
use Zend\Console\AdapterInterface as ConsoleAdapter;

/**
 * @category   Zend
 * @package    Zend_Console
 * @subpackage Prompt
 */
abstract class AbstractPrompt implements PromptInterface
{
    /**
     * @var Zend\Console\AdapterInterface
     */
    protected $console;

    /**
     * @var mixed
     */
    protected $lastResponse;

    public function show()
    {

    }

    /**
     * Return last answer to this prompt.
     *
     * @return mixed
     */
    public function getLastResponse()
    {
        return $this->lastResponse;
    }

    /**
     * Return console adapter to use when showing prompt.
     *
     * @return \Zend\Console\AdapterInterface
     */
    public function getConsole()
    {
        if (!$this->console) {
            $this->console = Console::getInstance();
        }

        return $this->console;
    }

    /**
     * Set console adapter to use when showing prompt.
     *
     * @param \Zend\Console\AdapterInterface $adapter
     */
    public function setConsole(ConsoleAdapter $adapter)
    {
        $this->console = $adapter;
    }
<commit_msg>Add convenience method to statically create prompts.<commit_after><?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 * @package   Zend_Console
 */

namespace Zend\Console\Prompt;

use Zend\Console\PromptInterface;
use Zend\Console\Console;
use Zend\Console\AdapterInterface as ConsoleAdapter;
use Zend\Console\Exception\BadMethodCallException;

/**
 * @category   Zend
 * @package    Zend_Console
 * @subpackage Prompt
 */
abstract class AbstractPrompt implements PromptInterface
{
    /**
     * @var Zend\Console\AdapterInterface
     */
    protected $console;

    /**
     * @var mixed
     */
    protected $lastResponse;

    abstract public function show();

    /**
     * Return last answer to this prompt.
     *
     * @return mixed
     */
    public function getLastResponse()
    {
        return $this->lastResponse;
    }

    /**
     * Return console adapter to use when showing prompt.
     *
     * @return \Zend\Console\AdapterInterface
     */
    public function getConsole()
    {
        if (!$this->console) {
            $this->console = Console::getInstance();
        }

        return $this->console;
    }

    /**
     * Set console adapter to use when showing prompt.
     *
     * @param \Zend\Console\AdapterInterface $adapter
     */
    public function setConsole(ConsoleAdapter $adapter)
    {
        $this->console = $adapter;
    }

    /**
     * Create an instance of this prompt, show it and return response.
     * 
     * This is a convenience method for creating statically creating prompts, i.e.:
     *
     *      $name = Zend\Console\Prompt\Line::prompt("Enter your name: ");
     *
     * @throws \Zend\Console\Exception\BadMethodCallException
     * @return mixed
     */
    public static function prompt(){
        if (get_called_class() === __CLASS__) {
            throw new BadMethodCallException(
                'Cannot call prompt() on AbstractPrompt class. Use one of Console\Prompt\ subclasses.'
            );
        }

        $refl     = new \ReflectionClass(get_called_class());
        $instance = $refl->newInstanceArgs(func_get_args());
        return $instance->show();
    }

{'fraction_non_alphanumeric': 0.11505321844906234, 'fraction_numerical': 0.00456158134820071, 'mean_word_length': 2.3850771869639793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1052062', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1094, 'n_words': 284}