master

laravel/framework

Last updated at: 29/12/2023 09:20

Secret.php

TLDR

This file contains a class called Secret which is a component for rendering a secret input field in the console.

Methods

render

Renders the component by creating a new Question object and setting it as hidden. Then, it asks the question using the Symfony Console askQuestion method. It returns the user's input as the secret value.

Classes

Class Secret

This class is a component for rendering a secret input field in the console. It extends the Component class. The render method is used to display the secret input field and retrieve the user's secret input.

<?php

namespace Illuminate\Console\View\Components;

use Symfony\Component\Console\Question\Question;

class Secret extends Component
{
    /**
     * Renders the component using the given arguments.
     *
     * @param  string  $question
     * @param  bool  $fallback
     * @return mixed
     */
    public function render($question, $fallback = true)
    {
        $question = new Question($question);

        $question->setHidden(true)->setHiddenFallback($fallback);

        return $this->usingQuestionHelper(fn () => $this->output->askQuestion($question));
    }
}