Вход Регистрация
Файл: vendor/laravel/prompts/src/ConfirmPrompt.php
Строк: 44
<?php

namespace LaravelPrompts;

use 
Closure;

class 
ConfirmPrompt extends Prompt
{
    
/**
     * Whether the prompt has been confirmed.
     */
    
public bool $confirmed;

    
/**
     * Create a new ConfirmPrompt instance.
     */
    
public function __construct(
        public 
string $label,
        public 
bool $default true,
        public 
string $yes 'Yes',
        public 
string $no 'No',
        public 
bool|string $required false,
        public 
mixed $validate null,
        public 
string $hint '',
        public ?
Closure $transform null,
    ) {
        
$this->confirmed $default;

        
$this->on('key'fn ($key) => match ($key) {
            
'y' => $this->confirmed true,
            
'n' => $this->confirmed false,
            
Key::TABKey::UPKey::UP_ARROWKey::DOWNKey::DOWN_ARROWKey::LEFTKey::LEFT_ARROWKey::RIGHTKey::RIGHT_ARROWKey::CTRL_PKey::CTRL_FKey::CTRL_NKey::CTRL_B'h''j''k''l' => $this->confirmed = ! $this->confirmed,
            
Key::ENTER => $this->submit(),
            default => 
null,
        });
    }

    
/**
     * Get the value of the prompt.
     */
    
public function value(): bool
    
{
        return 
$this->confirmed;
    }

    
/**
     * Get the label of the selected option.
     */
    
public function label(): string
    
{
        return 
$this->confirmed $this->yes $this->no;
    }
}
Онлайн: 2
Реклама